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



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

def content_length
  @content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) &&
                       (s =~ /^(\d+)$/)) ? $1.to_i : 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[HttpClient::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
# File 'lib/em-http/client.rb', line 29

def last_modified
  self[HttpClient::LAST_MODIFIED]
end

#locationObject



62
63
64
# File 'lib/em-http/client.rb', line 62

def location
  self[HttpClient::LOCATION]
end

#statusObject

HTTP response status as an integer



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

def status
  Integer(http_status) rescue 0
end