Skip to content
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

NetHttp backend only normalizes URLs when necesary #37

Merged
merged 2 commits into from
Dec 20, 2019

Conversation

coding-chimp
Copy link
Contributor

We also hit the issue mentioned in #35 today and since no-one took a crack at the proposed solution yet, I thought I'd do it. 🙂

@jrochkind
Copy link
Collaborator

Awesome! I'm still really uncomfortable with the previous/current behavior, this seems to me like a step in the right direction if it still meets @janko's needs?

(I also still wonder if there should be a flag to turn off this escaping altogether. The auto-escaping just seems wrong to me, in that it makes it it impossible to request certain URIs that actual HTTP servers can deliver; although I understand janko's argument that it messes people up too much when it's not there at all).

Copy link
Owner

@janko janko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I left a comment.

it "only normalizes URLs when URI says the URL is invalid" do
Addressable::URI.expects(:parse).never
Down::NetHttp.download("#{$httpbin}/etag/2ELk8hUpTC2wqJ%2BZ%25GfTFA.jpg")
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we could test actual behaviour rather than relying on implementation. The issue was that Addressable modifies the URL into something else. So I would like the test to assert that the request made was to the original URL, instead of the different URL that Addressable's normalization would produce.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't come up with a better way to test it, but that definitely makes sense. I updated the test so it's testing the base_uri of the tempfile.

@janko
Copy link
Owner

janko commented Dec 20, 2019

@jrochkind Yes, I agree we should add the ability to disable/override URI normalization, I'll open a separate issue where we can discuss that.

@janko
Copy link
Owner

janko commented Dec 20, 2019

Looks good, thank you! I will release a new patch version with your change, then in #35 I'd like to discuss improving Addressable normalization.

@janko janko merged commit de60c33 into janko:master Dec 20, 2019
@jrochkind
Copy link
Collaborator

y'all are awesome, @janko @coding-chimp !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants