lib/ftw/http/message.rb in ftw-0.0.13 vs lib/ftw/http/message.rb in ftw-0.0.14
- old
+ new
@@ -31,19 +31,19 @@
# Get a header value by field name.
#
# @param [String] the name of the field. (case insensitive)
def [](field)
- return @headers[header]
+ return @headers[field]
end # def []
# Set a header field
#
# @param [String] the name of the field. (case insensitive)
# @param [String] the value to set for this field
def []=(field, value)
- @headers[field] = header
+ @headers[field] = value
end # def []=
# Set the body of this message
#
# The 'message_body' can be an IO-like object, Enumerable, or String.
@@ -52,10 +52,10 @@
def body=(message_body)
# TODO(sissel): if message_body is a string, set Content-Length header
# TODO(sissel): if it's an IO object, set Transfer-Encoding to chunked
# TODO(sissel): if it responds to each or appears to be Enumerable, then
# set Transfer-Encoding to chunked.
- if message_body.is_a?(IO)
+ if message_body.respond_to?(:read) or message_body.respond_to?(:each)
headers["Transfer-Encoding"] = "chunked"
else
headers["Content-Length"] = message_body.length
end
@body = message_body