class Puppet::Indirector::FileMetadata::Http

Public Instance Methods

find(request) click to toggle source
   # File lib/puppet/indirector/file_metadata/http.rb
11 def find(request)
12   checksum_type = request.options[:checksum_type]
13   # See URL encoding comment in Puppet::Type::File::ParamSource#chunk_file_from_source
14   uri = URI(request.uri)
15   client = Puppet.runtime[:http]
16   head = client.head(uri, options: {include_system_store: true})
17 
18   return create_httpmetadata(head, checksum_type) if head.success?
19 
20   case head.code
21   when 403, 405
22     # AMZ presigned URL and puppetserver may return 403
23     # instead of 405. Fallback to partial get
24     get = partial_get(client, uri)
25     return create_httpmetadata(get, checksum_type) if get.success?
26   end
27 
28   nil
29 end

Private Instance Methods

create_httpmetadata(http_request, checksum_type) click to toggle source
   # File lib/puppet/indirector/file_metadata/http.rb
41 def create_httpmetadata(http_request, checksum_type)
42   metadata = Puppet::FileServing::HttpMetadata.new(http_request)
43   metadata.checksum_type = checksum_type if checksum_type
44   metadata.collect
45   metadata
46 end
partial_get(client, uri) click to toggle source
   # File lib/puppet/indirector/file_metadata/http.rb
37 def partial_get(client, uri)
38   client.get(uri, headers: {'Range' => 'bytes=0-0'}, options: {include_system_store: true})
39 end