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

Add Range header to HTTP::perform_head_request #425

Merged

Conversation

kylefleming
Copy link
Contributor

@kylefleming kylefleming commented Jan 25, 2018

Uses a GET request with a 1 byte Range header if the initial HEAD request fails. Falls back to a GET request without a Range header if that also fails.

Closes #420

Discussion

I've added the GET request with a Range header as an additional fallback and kept the original non-Range GET request as the final fallback. This is because I wasn't sure if we should expect that a server might respond to a normal GET request but return an error if the GET request includes a Range header.

My intuition would say that almost all servers that don't respond to a Range header would just ignore it and proceed as if it didn't exist. In this case, we wouldn't need the third non-Range fallback. Do we think this is a case that we would want to support? Having all 3 is the more conservative route, but adds additional latency in returning a result if the server doesn't have the content at all.

I think ideally we'd remove the third non-Range fallback, but I wanted to submit this PR with it in, in case it is decided that it's necessary.

Copy link
Member

@segiddins segiddins left a comment

Choose a reason for hiding this comment

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

Looks great, other than the one comment! Feel free to credit yourself in the CHANGELOG :)

@@ -45,7 +45,7 @@ def copy_fixture_to_pod(name, pod)
VCR.configure do |c|
c.cassette_library_dir = ROOT + 'spec/fixtures/vcr_cassettes'
c.hook_into :webmock
c.ignore_hosts 'codeclimate.com'
c.ignore_hosts 'codeclimate.com', 'some-url'
Copy link
Member

Choose a reason for hiding this comment

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

I dont think this host should be ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right.

I was thinking that if you forget to use WebMock to mock an endpoint, then VCR shouldn't try to handle it since it's not a legitimate URL to begin with and will never be recorded as a cassette. However, it's better that VCR complains about it than for Net::HTTP to try to connect to it.

@kylefleming
Copy link
Contributor Author

@segiddins Do you think it's preferable to have the original fallback GET request as a third fallback case, or just get rid of it entirely?

@kylefleming kylefleming force-pushed the perform_head_request_range_header branch from b29847b to fe29dd2 Compare January 25, 2018 06:27
kylefleming added a commit to kylefleming/Core that referenced this pull request Jan 25, 2018
@segiddins
Copy link
Member

Do you think it's preferable to have the original fallback GET request as a third fallback case, or just get rid of it entirely?

I think its a preferable fallback

@segiddins segiddins requested a review from orta January 25, 2018 16:26
@kylefleming
Copy link
Contributor Author

Shall I squash it?

@dnkoutso
Copy link
Contributor

@kylefleming sure

Uses a GET request with a 1 byte Range header if the initial HEAD request fails. Falls back to a GET request without a Range header if that also fails.
@kylefleming kylefleming force-pushed the perform_head_request_range_header branch from fe29dd2 to 5c700e2 Compare January 25, 2018 23:03
@dnkoutso dnkoutso merged commit 1653338 into CocoaPods:master Jan 26, 2018
@dnkoutso
Copy link
Contributor

danke!

@dnkoutso dnkoutso added this to the 1.5 milestone Jan 26, 2018
@kylefleming kylefleming deleted the perform_head_request_range_header branch January 26, 2018 18:00
@kylefleming
Copy link
Contributor Author

Do we have an estimate on when 1.5 will be released? Still waiting on this fix so I can push the latest OpenCV pod (CocoaPods/trunk.cocoapods.org#236).

@segiddins
Copy link
Member

@kylefleming not yet, but you can point to Core master using a gemfile to use it now: https://guides.cocoapods.org/using/unreleased-features.html

@kylefleming
Copy link
Contributor Author

@segiddins Thanks for the suggestion, but I actually need https://github.com/CocoaPods/trunk.cocoapods.org to be updated with this fix in order to push the pod.

@kylefleming
Copy link
Contributor Author

@segiddins Do you think it will be awhile before it's released? I'm inquiring so that I know whether I should be looking into workarounds or not.

@segiddins
Copy link
Member

I don't know how long it will be

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.

None yet

3 participants