HEX
Server: Apache
System: Linux dinesh8189 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: cgmgerenciamento1 (814285)
PHP: 8.1.26
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/file_serving/http_metadata.rb
require 'puppet/file_serving/metadata'

# Simplified metadata representation, suitable for the information
# that is available from HTTP headers.
class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata

  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}"

    # RFC-1864, deprecated in HTTP/1.1 due to partial responses
    checksum = http_response['content-md5']
    if checksum
      # convert base64 digest to hex
      checksum = checksum.unpack("m").first.unpack("H*").first
      @checksums[:md5] = "{md5}#{checksum}"
    end

    {
      md5: 'X-Checksum-Md5',
      sha1: 'X-Checksum-Sha1',
      sha256: 'X-Checksum-Sha256'
    }.each_pair do |checksum_type, header|
      checksum = http_response[header]
      if checksum
        @checksums[checksum_type] = "{#{checksum_type}}#{checksum}"
      end
    end

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

    @ftype = 'file'

    self
  end

  # Override of the parent class method. Does not call super!
  # We can only return metadata that was extracted from the
  # HTTP headers during #initialize.
  def collect
    # Prefer the checksum_type from the indirector request options
    # but fall back to the alternative otherwise
    [ @checksum_type, :md5, :sha256, :sha1, :mtime ].each do |type|
      @checksum_type = type
      @checksum = @checksums[type]
      break if @checksum
    end
  end
end