Re: Problem with mod_ruby and chunked transfer encoding
Brian Candler <[email protected]> Thu, 14 Oct 2004 16:14:35 +0100
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Oct 14, 2004 at 04:04:09PM +0100, Brian Candler wrote: > A simple patch is attached Erm, I think my original post didn't make it to the list, in which case this makes little sense - sorry! It's attached below. Regards, Brian. Date: Wed, 13 Oct 2004 11:07:51 +0100 From: Brian Candler <[email protected]> To: [email protected] Subject: Problem with mod_ruby and chunked transfer encoding Message-ID: <[email protected]> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i I have been trying to get mod_ruby to work with chunked transfer encoding. This is the program I'm testing with: ------------------------------------------------------------------------ $ cat ~ibn/public_html/prog2.rbx r = Apache.request r.setup_client_block(Apache::REQUEST_CHUNKED_DECHUNK) body = r.read r.headers_out['Content-Type'] = 'text/plain' r.send_http_header r << "Thank you for saying:" << body ------------------------------------------------------------------------ And this is what happens when I try to POST some chunked data: ------------------------------------------------------------------------ $ telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. POST /~ibn/prog2.rbx HTTP/1.1 Host: 127.0.0.1 Transfer-Encoding: chunked HTTP/1.1 411 Length Required Date: Wed, 13 Oct 2004 09:33:30 GMT Server: Apache/1.3.31 (Unix) mod_ruby/1.2.0 mod_fastcgi/2.4.2 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 168 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>411 Length Required</TITLE> </HEAD><BODY> <H1>Length Required</H1> A request of the requested method POST requires a valid Content-length.<P> chunked Transfer-Encoding forbidden: /~ibn/prog2.rbx<P> <HR> <ADDRESS>Apache/1.3.31 Server at localhost.my.domain Port 80</ADDRESS> </BODY></HTML> 0 Connection closed by foreign host. ------------------------------------------------------------------------ I was running apache-1.3.31_4, ruby-1.8.2.p2_1, mod_ruby-1.2.0 from FreeBSD ports. I know that mod_ruby-1.2.4 now exists, but the ports have not been updated yet; I've now upgraded, and the problem is the same. Now, looking at the source, in request.c I see if (r->read_length == 0) { if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) { rb_apache_exit(rc); } } 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 I tried removing these lines and reinstalling mod_ruby. Now I get a different problem: ------------------------------------------------------------------------ $ telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. POST /~ibn/prog2.rbx HTTP/1.1 Host: 127.0.0.1 Transfer-Encoding: chunked HTTP/1.1 200 OK Date: Wed, 13 Oct 2004 09:54:42 GMT Server: Apache/1.3.31 (Unix) mod_ruby/1.2.4 Ruby/1.8.2(2004-07-29) mod_fastcgi/2.4.2 Content-Type: text/plain Transfer-Encoding: chunked 15 Thank you for saying: 0 ------------------------------------------------------------------------ It doesn't wait for me to send the first chunk length. However I can fix this by changing body = r.read to body = r.read(1000000) in the Ruby code, and then it works correctly. Does anyone have any thoughts on this? Is there an underlying reason why mod_ruby should forbid chunked transfer encoding in all circumstances? (I see also very similar code in mod_perl, so they may be related) Many thanks, Brian Candler. P.S. there is a problem with the archives of this mailing list at http://lists.modruby.net/ml/archive/ If I click on either of the "(Search)" buttons, I get: Forbidden You don't have permission to access /ml/search/modruby/index.cgi on this server.