Class: EventMachine::NetHTTP::Response

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/em-net-http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/em-net-http.rb', line 10

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



10
11
12
# File 'lib/em-net-http.rb', line 10

def code
  @code
end

#headerObject (readonly)

Returns the value of attribute header.



10
11
12
# File 'lib/em-net-http.rb', line 10

def header
  @header
end

#http_versionObject (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

#messageObject (readonly) Also known as: msg

Returns the value of attribute message.



10
11
12
# File 'lib/em-net-http.rb', line 10

def message
  @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_typeObject



25
26
27
# File 'lib/em-net-http.rb', line 25

def content_type
  self['content-type']
end

#key?(k) ⇒ Boolean

Returns:

  • (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_hashObject



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