File: response_net_http.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (43 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
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
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

# Adapts Net::HTTPResponse to Puppet::HTTP::Response
#
# @api public
class Puppet::HTTP::ResponseNetHTTP < Puppet::HTTP::Response
  # Create a response associated with the URL.
  #
  # @param [URI] url
  # @param [Net::HTTPResponse] nethttp The response
  def initialize(url, nethttp)
    super(url, nethttp.code.to_i, nethttp.message)

    @nethttp = nethttp
  end

  # (see Puppet::HTTP::Response#body)
  def body
    @nethttp.body
  end

  # (see Puppet::HTTP::Response#read_body)
  def read_body(&block)
    raise ArgumentError, "A block is required" unless block_given?

    @nethttp.read_body(&block)
  end

  # (see Puppet::HTTP::Response#success?)
  def success?
    @nethttp.is_a?(Net::HTTPSuccess)
  end

  # (see Puppet::HTTP::Response#[])
  def [](name)
    @nethttp[name]
  end

  # (see Puppet::HTTP::Response#each_header)
  def each_header(&block)
    @nethttp.each_header(&block)
  end
end