Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Accept responses with no etag header"
This reverts commit 8414706. Since we made that change we added one spec that relied on responses without an Etag being accepted. That spec needs to be updated with a correct checksum since we no longer do that. Also, we add a regression spec for the issue being fixed here. Namely, if the gem server does not provide ETags, its responses don't have incremental content, but it still replies to partial range requests. In this situation, we want to fallback to making a full update so that things work.
- Loading branch information
1 parent
ada1ead
commit d8d3c69
Showing
4 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
bundler/spec/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "compact_index" | ||
|
||
Artifice.deactivate | ||
|
||
class CompactIndexPartialUpdateNoEtagNotIncremental < CompactIndexAPI | ||
def partial_update_no_etag | ||
response_body = yield | ||
headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60" | ||
content_type "text/plain" | ||
requested_range_for(response_body) | ||
end | ||
|
||
get "/versions" do | ||
partial_update_no_etag do | ||
file = tmp("versions.list") | ||
FileUtils.rm_f(file) | ||
file = CompactIndex::VersionsFile.new(file.to_s) | ||
file.create(gems) | ||
lines = file.contents.split("\n") | ||
|
||
# shuffle versions so new versions are not appended to the end | ||
[*lines[0..-2], lines.last.split(",").reverse.join(",")].join("\n") | ||
end | ||
end | ||
|
||
get "/info/:name" do | ||
partial_update_no_etag do | ||
gem = gems.find {|g| g.name == params[:name] } | ||
lines = CompactIndex.info(gem ? gem.versions : []).split("\n") | ||
|
||
# shuffle versions so new versions are not appended to the end | ||
[lines.first, lines.last, *lines[1..-2]].join("\n") | ||
end | ||
end | ||
end | ||
|
||
Artifice.activate_with(CompactIndexPartialUpdateNoEtagNotIncremental) |