class Puppet::Indirector::FileMetadata::Http

Public Instance Methods

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

Private Instance Methods

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