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
- #location ⇒ 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?
51 52 53 |
# File 'lib/em-http/client.rb', line 51 def chunked_encoding? /chunked/i === self[HttpClient::TRANSFER_ENCODING] end |
#compressed? ⇒ Boolean
59 60 61 |
# File 'lib/em-http/client.rb', line 59 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 43 |
# File 'lib/em-http/client.rb', line 40 def content_length @content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) && (s =~ /^(\d+)$/)) ? $1.to_i : nil end |
#cookie ⇒ Object
Cookie header from the server
46 47 48 |
# File 'lib/em-http/client.rb', line 46 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
55 56 57 |
# File 'lib/em-http/client.rb', line 55 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 |
#location ⇒ Object
63 64 65 |
# File 'lib/em-http/client.rb', line 63 def location self[HttpClient::LOCATION] 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 |