Class: EventMachine::AblyHttpRequest::HttpResponseHeader
- Inherits:
-
Hash
- Object
- Hash
- EventMachine::AblyHttpRequest::HttpResponseHeader
- Defined in:
- lib/em-http/http_header.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 (string - e.g. “OK”).
-
#http_status ⇒ Object
The status code (integer - e.g. 200).
-
#http_version ⇒ Object
The HTTP version returned (string - e.g. “1.1”).
-
#raw ⇒ Object
Raw headers.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#chunked_encoding? ⇒ Boolean
Is the transfer encoding chunked?.
- #client_error? ⇒ Boolean
- #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.
- #informational? ⇒ Boolean
- #keepalive? ⇒ Boolean
- #last_modified ⇒ Object
- #location ⇒ Object
- #redirection? ⇒ Boolean
- #server_error? ⇒ Boolean
-
#status ⇒ Object
HTTP response status.
- #successful? ⇒ Boolean
Instance Attribute Details
#http_reason ⇒ Object
The reason returned in the http response (string - e.g. “OK”)
7 8 9 |
# File 'lib/em-http/http_header.rb', line 7 def http_reason @http_reason end |
#http_status ⇒ Object
The status code (integer - e.g. 200)
13 14 15 |
# File 'lib/em-http/http_header.rb', line 13 def http_status @http_status end |
#http_version ⇒ Object
The HTTP version returned (string - e.g. “1.1”)
10 11 12 |
# File 'lib/em-http/http_header.rb', line 10 def http_version @http_version end |
#raw ⇒ Object
Raw headers
16 17 18 |
# File 'lib/em-http/http_header.rb', line 16 def raw @raw end |
Instance Method Details
#[](key) ⇒ Object
60 61 62 |
# File 'lib/em-http/http_header.rb', line 60 def [](key) super(key) || super(key.upcase.gsub('-','_')) end |
#chunked_encoding? ⇒ Boolean
Is the transfer encoding chunked?
44 45 46 |
# File 'lib/em-http/http_header.rb', line 44 def chunked_encoding? /chunked/i === self[HttpClient::TRANSFER_ENCODING] end |
#client_error? ⇒ Boolean
76 77 78 |
# File 'lib/em-http/http_header.rb', line 76 def client_error? 400 <= status && 500 > status end |
#compressed? ⇒ Boolean
52 53 54 |
# File 'lib/em-http/http_header.rb', line 52 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
33 34 35 36 |
# File 'lib/em-http/http_header.rb', line 33 def content_length @content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) && (s =~ /^(\d+)$/)) ? $1.to_i : nil end |
#cookie ⇒ Object
Cookie header from the server
39 40 41 |
# File 'lib/em-http/http_header.rb', line 39 def self[HttpClient::SET_COOKIE] end |
#etag ⇒ Object
E-Tag
19 20 21 |
# File 'lib/em-http/http_header.rb', line 19 def etag self[HttpClient::ETAG] end |
#informational? ⇒ Boolean
64 65 66 |
# File 'lib/em-http/http_header.rb', line 64 def informational? 100 <= status && 200 > status end |
#keepalive? ⇒ Boolean
48 49 50 |
# File 'lib/em-http/http_header.rb', line 48 def keepalive? /keep-alive/i === self[HttpClient::KEEP_ALIVE] end |
#last_modified ⇒ Object
23 24 25 |
# File 'lib/em-http/http_header.rb', line 23 def last_modified self[HttpClient::LAST_MODIFIED] end |
#location ⇒ Object
56 57 58 |
# File 'lib/em-http/http_header.rb', line 56 def location self[HttpClient::LOCATION] end |
#redirection? ⇒ Boolean
72 73 74 |
# File 'lib/em-http/http_header.rb', line 72 def redirection? 300 <= status && 400 > status end |
#server_error? ⇒ Boolean
80 81 82 |
# File 'lib/em-http/http_header.rb', line 80 def server_error? 500 <= status && 600 > status end |
#status ⇒ Object
HTTP response status
28 29 30 |
# File 'lib/em-http/http_header.rb', line 28 def status Integer(http_status) rescue 0 end |
#successful? ⇒ Boolean
68 69 70 |
# File 'lib/em-http/http_header.rb', line 68 def successful? 200 <= status && 300 > status end |