Class: HttpVanilli::NetHttp::Response
- Defined in:
- lib/http_vanilli/net_http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(code, headers, body, message = StatusMessage[code.to_i]) ⇒ Response
constructor
A new instance of Response.
- #to_net_http ⇒ Object
Constructor Details
#initialize(code, headers, body, message = StatusMessage[code.to_i]) ⇒ Response
Returns a new instance of Response.
15 16 17 18 |
# File 'lib/http_vanilli/net_http/response.rb', line 15 def initialize(code,headers,body,=StatusMessage[code.to_i]) @code,@body,@message = code.to_i,body, @headers = headers || {} end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
12 13 14 |
# File 'lib/http_vanilli/net_http/response.rb', line 12 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/http_vanilli/net_http/response.rb', line 13 def code @code end |
#headers ⇒ Object
Returns the value of attribute headers.
12 13 14 |
# File 'lib/http_vanilli/net_http/response.rb', line 12 def headers @headers end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
13 14 15 |
# File 'lib/http_vanilli/net_http/response.rb', line 13 def @message end |
Instance Method Details
#to_net_http ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/http_vanilli/net_http/response.rb', line 24 def to_net_http response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, ) response.instance_variable_set(:@body, body) if body headers.each { |name, value| response[name] = value } response.instance_variable_set(:@read, true) response.extend HttpVanilli::NetHttp::ResponseMixin response end |