Class: Gemkeeper::CompactIndexServer::RubygemsClient
- Inherits:
-
Object
- Object
- Gemkeeper::CompactIndexServer::RubygemsClient
- Defined in:
- lib/gemkeeper/compact_index_server/rubygems_client.rb
Overview
HTTP client for RubyGems.org compact index endpoints. Speaks conditional GET (ETag) and gzip; raises UpstreamUnavailableError on any network failure so callers can fall back to cache.
Constant Summary collapse
- HOST =
"rubygems.org"- OPEN_TIMEOUT =
5- READ_TIMEOUT =
10
Instance Method Summary collapse
-
#get(path, if_none_match = nil) ⇒ Object
Returns :not_modified, or body:, etag:.
Instance Method Details
#get(path, if_none_match = nil) ⇒ Object
Returns :not_modified, or body:, etag:.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gemkeeper/compact_index_server/rubygems_client.rb', line 19 def get(path, if_none_match = nil) uri = URI("https://#{HOST}#{path}") req = build_request(uri, if_none_match) Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: OPEN_TIMEOUT, read_timeout: READ_TIMEOUT) do |http| interpret(http.request(req)) end rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout, Net::ReadTimeout, SocketError, OpenSSL::SSL::SSLError => error raise UpstreamUnavailableError, error. end |