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/http/response.rb
#
# @api private
#
# Represents the response returned from the server from an HTTP request
#
class Puppet::HTTP::Response
  # @api private
  # @return [Net::HTTP] the Net::HTTP response
  attr_reader :nethttp

  # @api private
  # @return [URI] the response uri
  attr_reader :url

  #
  # @api private
  #
  # Object to represent the response returned from an HTTP request
  #
  # @param [Net::HTTP] nethttp the request response
  # @param [URI] url
  #
  def initialize(nethttp, url)
    @nethttp = nethttp
    @url = url
  end

  #
  # @api private
  #
  # Extract the response code
  #
  # @return [Integer] Response code for the request
  #
  def code
    @nethttp.code.to_i
  end

  #
  # @api private
  #
  # Extract the response message
  #
  # @return [String] Response message for the request
  #
  def reason
    @nethttp.message
  end

  #
  # @api private
  #
  # Returns the entire response body. Can be used instead of
  #   Puppet::HTTP::Response.read_body, but both methods cannot be used for the
  #   same response.
  #
  # @return [String] Response body for the request
  #
  def body
    @nethttp.body
  end

  #
  # @api private
  #
  # Streams the response body to the caller in chunks. Can be used instead of
  #   Puppet::HTTP::Response.body, but both methods cannot be used for the same
  #   response.
  #
  # @yield [String] Streams the response body in chunks
  #
  # @raise [ArgumentError] raise if a block is not given
  #
  def read_body(&block)
    raise ArgumentError, "A block is required" unless block_given?

    @nethttp.read_body(&block)
  end

  #
  # @api private
  #
  # Check if the request received a response of success
  #
  # @return [Boolean] Returns true if the response indicates success
  #
  def success?
    @nethttp.is_a?(Net::HTTPSuccess)
  end

  # @api private
  #
  # Get a header case-insensitively.
  # @param [String] name The header name
  # @return [String] The header value
  #
  def [](name)
    @nethttp[name]
  end

  # @api private
  #
  # Yield each header name and value. Returns an enumerator if no block is given.
  #
  # @yieldparam [String] header name
  # @yieldparam [String] header value
  #
  def each_header(&block)
    @nethttp.each_header(&block)
  end

  # @api private
  #
  # Drain the response body.
  #
  def drain
    body
    true
  end
end