Class: EventMachine::NetHTTP::Response
- Inherits:
-
Object
- Object
- EventMachine::NetHTTP::Response
- Includes:
- Enumerable
- Defined in:
- lib/em-net-http.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#http_version ⇒ Object
readonly
Returns the value of attribute http_version.
-
#message ⇒ Object
(also: #msg)
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #content_type ⇒ Object
-
#initialize(response_header) ⇒ Response
constructor
A new instance of Response.
- #key?(k) ⇒ Boolean
- #read_body(dest = nil, &block) ⇒ Object
- #set_body(body) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(response_header) ⇒ Response
Returns a new instance of Response.
13 14 15 16 17 18 |
# File 'lib/em-net-http.rb', line 13 def initialize(response_header) @code = response_header.http_status.to_s @message = response_header.http_reason @http_version = response_header.http_version @header = response_header end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/em-net-http.rb', line 10 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/em-net-http.rb', line 10 def code @code end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
10 11 12 |
# File 'lib/em-net-http.rb', line 10 def header @header end |
#http_version ⇒ Object (readonly)
Returns the value of attribute http_version.
10 11 12 |
# File 'lib/em-net-http.rb', line 10 def http_version @http_version end |
#message ⇒ Object (readonly) Also known as: msg
Returns the value of attribute message.
10 11 12 |
# File 'lib/em-net-http.rb', line 10 def @message end |
Instance Method Details
#[](k) ⇒ Object
29 30 31 |
# File 'lib/em-net-http.rb', line 29 def [](k) @header[key(k)] end |
#content_type ⇒ Object
25 26 27 |
# File 'lib/em-net-http.rb', line 25 def content_type self['content-type'] end |
#key?(k) ⇒ Boolean
33 34 35 |
# File 'lib/em-net-http.rb', line 33 def key?(k) @header.key? key(k) end |
#read_body(dest = nil, &block) ⇒ Object
37 38 39 |
# File 'lib/em-net-http.rb', line 37 def read_body(dest=nil,&block) @body end |
#set_body(body) ⇒ Object
20 21 22 23 |
# File 'lib/em-net-http.rb', line 20 def set_body body @already_buffered = true @body = body end |
#to_hash ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/em-net-http.rb', line 41 def to_hash h={} @header.each do |k, v| h[fromkey(k)] = v end h end |