lib/em-http/http_header.rb in em-http-request-1.0.3 vs lib/em-http/http_header.rb in em-http-request-1.1.0
- old
+ new
@@ -23,11 +23,11 @@
self[HttpClient::LAST_MODIFIED]
end
# HTTP response status as an integer
def status
- Integer(http_status) rescue 0
+ @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]) &&
@@ -56,8 +56,28 @@
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