Method: FTW::Protocol#read_http_body
- Defined in:
- lib/ftw/protocol.rb
#read_http_body(&block) ⇒ Object
Read the body of this message. The block is called with chunks of the response as they are read in.
This method is generally only called by http clients, not servers.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ftw/protocol.rb', line 104 def read_http_body(&block) if @body.respond_to?(:read) if headers.include?("Content-Length") and headers["Content-Length"].to_i > 0 @logger.debug("Reading body with Content-Length") read_http_body_length(headers["Content-Length"].to_i, &block) elsif headers["Transfer-Encoding"] == "chunked" @logger.debug("Reading body with chunked encoding") read_http_body_chunked(&block) end # If this is a poolable resource, release it (like a FTW::Connection) @body.release if @body.respond_to?(:release) elsif !@body.nil? block.call(@body) end end |