Re: Problem with mod_ruby and chunked transfer encoding

Shugo Maeda <[email protected]> Fri, 15 Oct 2004 02:18:17 +0900
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
Hi,

Brian Candler wrote:
>>This seems to say that chunked transfer encoding is explicitly disabled for
>>every request. Why should this be? I know that older versions of Apache had
>>a bug, but this was fixed in 1.3.26
> 
> 
> A simple patch is attached, which allows chunking by default, unless the
> Apache version is too old.

Currently Apache::Request#read does not support chunked transfer-encoding.

Please use Apache::Request#get_client_block like this.

--------------------------------------------
SUFFICIENT_BLOCK_SIZE = 1024000
r = Apache.request
if r.headers_in["Transfer-Encoding"] == "chunked"
  body = ""
  r.setup_client_block(Apache::REQUEST_CHUNKED_DECHUNK)
  if r.should_client_block
    while (buf = r.get_client_block(SUFFICIENT_BLOCK_SIZE)) &&
          !buf.empty?
      body.concat(buf)
    end
  end
else
  body = r.read
end
r.content_type = "text/plain"
r.send_http_header
r.print(body)
--------------------------------------------

Please note that Apache::Request#get_client_block of mod_ruby-1.2.4
returns "" for EOF, but the one of the svn head returns nil instead
of "".

Shugo