-
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
Add the location to all responses returned #96
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! I will check soon! 👍 |
If we merge this we will include location to the struct and it will be harder to remove as we would need to deprecate etc etc. I'm not sure if it's better to wait for the next hackney version or keep it for now. Any thoughts @ShaneWilton and @benoitc? |
I think that having the client will be really useful to give proper tools for request and response streaming (#97) |
I'd agree with the deprecation point. I'm happy to wait for the next version of Hackney, then swap out the location for the client. Calling into Hackney directly isn't too bad. |
What if we expose What do you think? |
Sorry about vanishing for a while, I got swamped with other work. I just looked into this again, and as far as I can tell, the |
which change to client_ref? |
there is an update of hackney that will land sometimes this week which simplify the api. It will be easier to retrieve and reuse the location with it. |
@benoitc Right now, reading the body off a Ideally, we'd like to return the |
OK I see. It should be handled in the coming version then :) I will try to publish it before friday. |
Has Hackney added the update this is waiting on? I'd love to see this feature merged! |
I also would like to know if there is any roadblock from getting this to merge. |
Would still love to see this make the 1.0.0 release cycle! |
It seams the |
Any news on that ? I would love to see this feature too |
Yeah, still no news on the subject? I would really need to have the location of the response as well. |
@edgurgel is there anything I can help with to make this be included into HTTPoison? |
@bitboxer yes! Would you mind setting up a new PR with the necessary changes? I'm keen to get this merged 👍 |
@edgurgel okay, will try do this tonight. |
well why not using hackney:get_location? i'm confused. |
@benoitc now you are confusing me 😉 . What do you mean by that? |
{:ok, status_code, headers, client} -> | ||
location = :hackney.location(client) # FIXME The current version of Hackney (0.8) requires that we read the location before the body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitc, do you mean this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah probably :) i need to think on a better way to keep that state..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does that mean I should not rework this PR to make it work against the current httpoison codebase and wait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just keep moving as this has been open for a while. We can always rework it if hackney changes in the future. Thanks for pushing this :D
This closes #90
There's two things to note in this pull request:
We're forced to read the location off of the
client_ref()
before we read the body. In the current version of Hackney, reading the body destroys thatclient_ref()
. A new release of Hackney will be released within the next week or so that resolves this issue, at which point we can inline the call to:hackney.location(client)
In the cases where a
client_ref()
is not returned, I've chosen to returnnil
as the location. I would prefer always returning the location, but defaulting torequest_url
is not reliable. Both HEAD requests and requests that make use of thewith_body
parameter are still capable of following redirects, but will not return aclient_ref()
. Let me know if you'd prefer different behaviour here.I'm happy to modify this pull request once we get the new version of Hackney. Once we have that, I'll also open a new PR to return the
client_ref()