/usr/lib/ruby/vendor_ruby/em-http/http_header.rb is in ruby-em-http-request 1.1.5-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | module EventMachine
# A simple hash is returned for each request made by HttpClient with the
# headers that were given by the server for that request.
class HttpResponseHeader < Hash
# The reason returned in the http response (string - e.g. "OK")
attr_accessor :http_reason
# The HTTP version returned (string - e.g. "1.1")
attr_accessor :http_version
# The status code (integer - e.g. 200)
attr_accessor :http_status
# Raw headers
attr_accessor :raw
# E-Tag
def etag
self[HttpClient::ETAG]
end
def last_modified
self[HttpClient::LAST_MODIFIED]
end
# HTTP response status
def status
Integer(http_status) rescue 0
end
# Length of content as an integer, or nil if chunked/unspecified
def content_length
@content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) &&
(s =~ /^(\d+)$/)) ? $1.to_i : nil
end
# Cookie header from the server
def cookie
self[HttpClient::SET_COOKIE]
end
# Is the transfer encoding chunked?
def chunked_encoding?
/chunked/i === self[HttpClient::TRANSFER_ENCODING]
end
def keepalive?
/keep-alive/i === self[HttpClient::KEEP_ALIVE]
end
def compressed?
/gzip|compressed|deflate/i === self[HttpClient::CONTENT_ENCODING]
end
def location
self[HttpClient::LOCATION]
end
def [](key)
super(key) || super(key.upcase.gsub('-','_'))
end
def informational?
100 <= status && 200 > status
end
def successful?
200 <= status && 300 > status
end
def redirection?
300 <= status && 400 > status
end
def client_error?
400 <= status && 500 > status
end
def server_error?
500 <= status && 600 > status
end
end
end
|