-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPoison.AsyncResponse id's can be {:maybe_redirect_response, status, headers, client} #424
Conversation
…, headers, client}
@vereis Thanks for the very detailed explanation 🏆 I agree that the result is a bit weird given that the id is a tuple 🤔 I would consider this a bug tbh... Maybe the best solution is to return a different struct as you suggested? What do you think? |
Yeah that sounds better, I just didn't want to do too much out of nowhere, but yeah this seems more like a bug! Maybe I should have created an issue first 😅 I think we can just handle where this gets returned and check if it looks like a If we go with something like Perhaps since manual intervention is required this is moreso an If we wanted to handle this explicitly we could perhaps also add a function |
I like this. Most people won't need to worry as it's not super easy to get to this case?
Maybe we could wait for more feedback once we release the new struct? What do you think? |
Yeah exactly, this makes sense to me. I'll give it a shot and update this MR. Thanks for clarifying 💪 |
Nice one! I intend to release a new version soon. Cheers! 🎉 |
@edgurgel Can you please release a new version with these changes? |
Yes! Absolutely! I completely forgot about this! 🤦 I will do it later today! |
Updating HTTPoison to 1.8 which includes edgurgel/httpoison#424, implementing proper handling of redirects. However, WIP because: - edgurgel/httpoison#453 - need to investigate whether the same (handling %HTTPoison.MaybeRedirect{} results) is needed for other requests (e.g. options)
Updating HTTPoison to 1.8 which includes edgurgel/httpoison#424, implementing proper handling of redirects. However, WIP because: - edgurgel/httpoison#453 - need to investigate whether the same (handling %HTTPoison.MaybeRedirect{} results) is needed for other requests (e.g. options)
Updated HTTPoison to 1.8 which includes edgurgel/httpoison#424, implementing proper handling of redirects. Additionally, we now follow redirects for all HTTP methods (not just PATCH). NOTES (in order of importance): - POST requests which receive a 303 respose are followed internally by HTTPoison but with the GET method, thus if the server replies 303 to a POST request the tus upload will not work properly - there is no redirect loop detection, it may make sense to add an option (with a default) to limit the max number of redirects - edgurgel/httpoison#453 is manually worked around
I ran into the following situation working with a
script.google.com/...
API:POST-ing to a URL which returned a
302
meant that redirection was not followed because:hackney
will only follow redirects if a POST request status was304
, but iffollow_redirects: true
is given as a request option,HTTPoison
returns:{:ok, %HTTPoison.AsyncResponse{id: {:maybe_redirect, ..., ..., ...}}
Passing
hackney: [force_redirects: true]
to the request to try to circumvent this does not work as expected, because:hackney
doesn't follow the spec and change themethod
toGET
, causing the request to return a405
.For my use case, handling the error is perfectly fine, but unfortunately dialyzer complains about the following match because the
HTTPoison.AsyncResponse
'sid
is not a reference but instead just a tuple probably bubbling up from:hackney
:Not sure if this was known behaviour, but if so I've amended the type spec in this MR although perhaps one should return a different struct altogether?