Method: Puppet::FileServing::HttpMetadata#initialize

Defined in:
lib/puppet/file_serving/http_metadata.rb

#initialize(http_response, path = '/dev/null') ⇒ HttpMetadata

Returns a new instance of HttpMetadata.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet/file_serving/http_metadata.rb', line 7

def initialize(http_response, path = '/dev/null')
  super(path)

  # ignore options that do not apply to HTTP metadata
  @owner = @group = @mode = nil

  # hash available checksums for eventual collection
  @checksums = {}
  # use a default mtime in case there is no usable HTTP header
  @checksums[:mtime] = "{mtime}#{Time.now}"

  if checksum = http_response['content-md5']
    # convert base64 digest to hex
    checksum = checksum.unpack("m0").first.unpack("H*").first
    @checksums[:md5] = "{md5}#{checksum}"
  end

  if last_modified = http_response['last-modified']
    mtime = DateTime.httpdate(last_modified).to_time
    @checksums[:mtime] = "{mtime}#{mtime.utc}"
  end

  @ftype = 'file'

  self
end