lib/ftw/http/message.rb in ftw-0.0.1 vs lib/ftw/http/message.rb in ftw-0.0.4

- old
+ new

@@ -56,10 +56,18 @@ # or 304 MUST NOT have a body. All other requests have a message body, # even if that body is of zero length. return @body end # def body - # Does this message have a message body? + # Does this message have a message body / content? + public + def content? + # In HTTP 1.1, there is a body if response sets Content-Length *or* + # Transfer-Encoding, it has a body. Otherwise, there is no body. + return (headers.include?("Content-Length") and headers["Content-Length"].to_i > 0) \ + || headers.include?("Transfer-Encoding") + end # def content? + public def body? return @body.nil? end # def body?