Class: Puppet::HTTP::Response Private
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents the response returned from the server from an HTTP request
Instance Attribute Summary collapse
-
#nethttp ⇒ Net::HTTP
readonly
private
The Net::HTTP response.
-
#url ⇒ URI
readonly
private
The response uri.
Instance Method Summary collapse
-
#[](name) ⇒ String
private
Get a header case-insensitively.
-
#body ⇒ String
private
Returns the entire response body.
-
#code ⇒ Integer
private
Extract the response code.
-
#drain ⇒ Object
private
Drain the response body.
-
#each_header {|header, header| ... } ⇒ Object
private
Yield each header name and value.
-
#initialize(nethttp, url) ⇒ Response
constructor
private
Object to represent the response returned from an HTTP request.
-
#read_body {|String| ... } ⇒ Object
private
Streams the response body to the caller in chunks.
-
#reason ⇒ String
private
Extract the response message.
-
#success? ⇒ Boolean
private
Check if the request received a response of success.
Constructor Details
#initialize(nethttp, url) ⇒ Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Object to represent the response returned from an HTTP request
23 24 25 26 |
# File 'lib/puppet/http/response.rb', line 23 def initialize(nethttp, url) @nethttp = nethttp @url = url end |
Instance Attribute Details
#nethttp ⇒ Net::HTTP (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the Net::HTTP response.
9 10 11 |
# File 'lib/puppet/http/response.rb', line 9 def nethttp @nethttp end |
#url ⇒ URI (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the response uri.
13 14 15 |
# File 'lib/puppet/http/response.rb', line 13 def url @url end |
Instance Method Details
#[](name) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a header case-insensitively.
97 98 99 |
# File 'lib/puppet/http/response.rb', line 97 def [](name) @nethttp[name] end |
#body ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
59 60 61 |
# File 'lib/puppet/http/response.rb', line 59 def body @nethttp.body end |
#code ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extract the response code
35 36 37 |
# File 'lib/puppet/http/response.rb', line 35 def code @nethttp.code.to_i end |
#drain ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Drain the response body.
116 117 118 119 |
# File 'lib/puppet/http/response.rb', line 116 def drain body true end |
#each_header {|header, header| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Yield each header name and value. Returns an enumerator if no block is given.
108 109 110 |
# File 'lib/puppet/http/response.rb', line 108 def each_header(&block) @nethttp.each_header(&block) end |
#read_body {|String| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
74 75 76 77 78 |
# File 'lib/puppet/http/response.rb', line 74 def read_body(&block) raise ArgumentError, "A block is required" unless block_given? @nethttp.read_body(&block) end |
#reason ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extract the response message
46 47 48 |
# File 'lib/puppet/http/response.rb', line 46 def reason @nethttp. end |
#success? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the request received a response of success
87 88 89 |
# File 'lib/puppet/http/response.rb', line 87 def success? @nethttp.is_a?(Net::HTTPSuccess) end |