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

Follow relative locations correctly. Fixes #228 #230

Merged
merged 4 commits into from
May 21, 2018
Merged

Conversation

ioquatix
Copy link
Member

@ioquatix ioquatix commented Apr 6, 2018

No description provided.

@perlun
Copy link
Contributor

perlun commented Apr 9, 2018

Thanks @ioquatix! I looked at your implementation, it looks good.

Please fix the minor issues reported by Travis also: https://travis-ci.org/rack-test/rack-test/jobs/363348025 and I'll approve this change
(for the file length cop you can auto-regenerate the .rubocop_todo.yml file, rubocop --auto-gen)

@ioquatix
Copy link
Member Author

ioquatix commented Apr 9, 2018

I don't know why but Travis didn't seem to re-run the tests. However I think I fixed all (most?) of the issues.

@ioquatix
Copy link
Member Author

@perlun Are we good to go with this?

lib/rack/test.rb Outdated

# Compute the next location by appending the location header with the
# last request, as per https://tools.ietf.org/html/rfc7231#section-7.1.2
next_location = URI.parse(last_request.url) + URI.parse(last_response['Location'])
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought about this a bit more: does this work if Location is an absolute URL? It feels like it wouldn't. So please add a test case for that, and if it works => fine, but if not I think we'll need to adjust the implementation a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

When you add two absolute locations the RHS is returned. That's the behaviour of URI RFC.

Copy link
Member Author

Choose a reason for hiding this comment

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

2.5.0 :001 > require 'uri'
 => false 
2.5.0 :002 > URI.parse("http://www.google.com") + URI.parse("http://www.yahoo.com")
 => #<URI::HTTP http://www.yahoo.com> 
2.5.0 :003 > 

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, sounds great! Would you mind adding a test that documents these semantics? You could even write a comment saying that '# Adding two absolute locations returns the right-hand location or something to the like.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping @ioquatix

@perlun
Copy link
Contributor

perlun commented Apr 19, 2018

@ioquatix Thanks for the update. I realized there might be some more issues with this - noted above.

@ioquatix
Copy link
Member Author

ioquatix commented May 2, 2018

Okay done.

@ioquatix
Copy link
Member Author

Can we merge this?

@perlun
Copy link
Contributor

perlun commented May 21, 2018

@ioquatix

Can we merge this?

There was still a Travis issue, I've fixed that now and Travis is green again. Merging - thanks for your contributions! 👍

@perlun perlun merged commit 88559dc into rack:master May 21, 2018
alex-damian-negru pushed a commit to alex-damian-negru/rack-test that referenced this pull request Apr 5, 2021
* Follow relative locations correctly. Fixes rack#228

* Add spec for absolute URLs.

* Regenerated Rubocop config
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.

2 participants