Class: EventMachine::HttpResponseHeader

Inherits:
Hash
  • Object
show all
Defined in:
lib/em-http/client.rb

Overview

A simple hash is returned for each request made by HttpClient with the headers that were given by the server for that request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

from_array, #to_params

Instance Attribute Details

#http_reasonObject

The reason returned in the http response (“OK”,“File not found”,etc.)



16
17
18
# File 'lib/em-http/client.rb', line 16

def http_reason
  @http_reason
end

#http_statusObject

The status code (as a string!)



22
23
24
# File 'lib/em-http/client.rb', line 22

def http_status
  @http_status
end

#http_versionObject

The HTTP version returned.



19
20
21
# File 'lib/em-http/client.rb', line 19

def http_version
  @http_version
end

Instance Method Details

#chunked_encoding?Boolean

Is the transfer encoding chunked?

Returns:

  • (Boolean)


50
51
52
# File 'lib/em-http/client.rb', line 50

def chunked_encoding?
  /chunked/i === self[HttpClient::TRANSFER_ENCODING]
end

#compressed?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/em-http/client.rb', line 58

def compressed?
  /gzip|compressed|deflate/i === self[HttpClient::CONTENT_ENCODING]
end

#content_lengthObject

Length of content as an integer, or nil if chunked/unspecified



40
41
42
# File 'lib/em-http/client.rb', line 40

def content_length
  Integer(self[HttpClient::CONTENT_LENGTH]) rescue nil
end

Cookie header from the server



45
46
47
# File 'lib/em-http/client.rb', line 45

def cookie
  self[HttpClient::SET_COOKIE]
end

#etagObject

E-Tag



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

def etag
  self["ETag"]
end

#keep_alive?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/em-http/client.rb', line 54

def keep_alive?
  /keep-alive/i === self[HttpClient::KEEP_ALIVE]
end

#last_modifiedObject



29
30
31
32
# File 'lib/em-http/client.rb', line 29

def last_modified
  time = self["Last-Modified"]
  Time.parse(time) if time
end

#statusObject

HTTP response status as an integer



35
36
37
# File 'lib/em-http/client.rb', line 35

def status
  Integer(http_status) rescue nil
end