Class: EventMachine::HttpResponseHeader
- 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
-
#http_reason ⇒ Object
The reason returned in the http response (“OK”,“File not found”,etc.).
-
#http_status ⇒ Object
The status code (as a string!).
-
#http_version ⇒ Object
The HTTP version returned.
Instance Method Summary collapse
-
#chunked_encoding? ⇒ Boolean
Is the transfer encoding chunked?.
- #compressed? ⇒ Boolean
-
#content_length ⇒ Object
Length of content as an integer, or nil if chunked/unspecified.
-
#cookie ⇒ Object
Cookie header from the server.
-
#etag ⇒ Object
E-Tag.
- #keep_alive? ⇒ Boolean
- #last_modified ⇒ Object
-
#status ⇒ Object
HTTP response status as an integer.
Methods inherited from Hash
Instance Attribute Details
#http_reason ⇒ Object
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_status ⇒ Object
The status code (as a string!)
22 23 24 |
# File 'lib/em-http/client.rb', line 22 def http_status @http_status end |
#http_version ⇒ Object
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?
50 51 52 |
# File 'lib/em-http/client.rb', line 50 def chunked_encoding? /chunked/i === self[HttpClient::TRANSFER_ENCODING] end |
#compressed? ⇒ Boolean
58 59 60 |
# File 'lib/em-http/client.rb', line 58 def compressed? /gzip|compressed|deflate/i === self[HttpClient::CONTENT_ENCODING] end |
#content_length ⇒ Object
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 ⇒ Object
Cookie header from the server
45 46 47 |
# File 'lib/em-http/client.rb', line 45 def self[HttpClient::SET_COOKIE] end |
#etag ⇒ Object
E-Tag
25 26 27 |
# File 'lib/em-http/client.rb', line 25 def etag self["ETag"] end |
#keep_alive? ⇒ Boolean
54 55 56 |
# File 'lib/em-http/client.rb', line 54 def keep_alive? /keep-alive/i === self[HttpClient::KEEP_ALIVE] end |
#last_modified ⇒ Object
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 |
#status ⇒ Object
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 |