Method: Puppet::Indirector::FileMetadata::Http#find

Defined in:
lib/puppet/indirector/file_metadata/http.rb

#find(request) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/puppet/indirector/file_metadata/http.rb', line 13

def find(request)
  checksum_type = request.options[:checksum_type]
  # See URL encoding comment in Puppet::Type::File::ParamSource#chunk_file_from_source
  uri = URI(request.uri)
  client = Puppet.runtime[:http]
  head = client.head(uri, options: { include_system_store: true })

  return (head, checksum_type) if head.success?

  case head.code
  when 403, 405
    # AMZ presigned URL and puppetserver may return 403
    # instead of 405. Fallback to partial get
    get = partial_get(client, uri)
    return (get, checksum_type) if get.success?
  end

  nil
end