forked from ansalond/truffleruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify patches related to downloading HTTPS
* The patch in rubygems/remote_fetcher.rb is not needed, as removing just goes through the rubygems/request.rb patch. * wget is no longer needed. * Share code to perform a https request and return a Net::HTTPResponse using curl. * Only patch the https path, let other requests use the original implementation to minimize the patch size.
- Loading branch information
Showing
7 changed files
with
59 additions
and
215 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'net/http' | ||
|
||
module Truffle | ||
module HTTPSDownloader | ||
HTTP_PROXY_HEADER = "HTTP/1.0 200 Connection established\r\n\r\n" | ||
|
||
class CurlResponse < Net::HTTPOK | ||
def body | ||
@body | ||
end | ||
end | ||
|
||
def self.download(uri) | ||
resp = CurlResponse.new('1.1', 200, 'OK') | ||
raise 'curl is missing' unless (`curl --help` rescue nil) | ||
resp_raw = `curl -i -s #{uri}` | ||
index_offset = resp_raw.start_with?(HTTP_PROXY_HEADER) ? HTTP_PROXY_HEADER.size : 0 | ||
blank_line_idx = resp_raw.index("\r\n\r\n", index_offset) | ||
header = resp_raw[0...blank_line_idx] | ||
resp.body = resp_raw[(blank_line_idx+4)..-1] | ||
|
||
if m = /ETag: (\"[[:alnum:]]*\")/.match(header) | ||
resp['ETag'] = m[1] | ||
end | ||
resp | ||
end | ||
|
||
def self.download_to(uri, path) | ||
raise 'curl is missing' unless (`curl --help` rescue nil) | ||
system 'curl', '-s', uri, '-o', path | ||
end | ||
end | ||
end |
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