If I have the following .shtml file: <!--#include virtual="/cgi-bin/redir" --> Got to end! And /cgi-bin/redir is a script like: #!/bin/sh echo 'Location: /foo.html' echo '' Then I'll see the contents of foo.html, but not the "Got to end" message. This works fine in Apache 1.x.
Works for me with HEAD of httpd. Please try Apache 2.0.44. Thanks for using Apache HTTP Server!
Still broken under 2.0.44. I've poked around a bit more and figured out some additional details; it looks like this is a problem with interaction between chunked encoding and mod_include: --- dozer% cat test-apache2-redir.shtml <!--#include virtual="/cgi-bin/redirtest" --> Got to end! dozer% cat foo.html hiya dozer% cat ~/apache/cgi-bin/redirtest #!/bin/sh echo Location: /foo.html echo '' dozer% nc dozer 8763 GET /test-apache2-redir.shtml HTTP/1.1 Host: dozer.ironplanet.com:8763 HTTP/1.1 200 OK Date: Mon, 17 Feb 2003 19:09:24 GMT Server: Apache/2.0.44 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0210222112 Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=ISO-8859-1 5 hiya 0 0 d Got to end! 0 --- Notice that although the "got to end" message *does* make it through, it comes through *after* not one but two 0-length chunks, each of which is supposed to indicate the end of the document (see RFC2616 section 3.6.1). If you hit this URL with Mozilla or MSIE or links, you just see the "hiya" message. Now, if I replace the include of the CGI script with a direct include of /foo.html, the result is much more reasonable: --- dozer% cat test-apache2-redir2.shtml <!--#include virtual="/foo.html" --> Got to end! dozer% nc dozer 8763 GET /test-apache2-redir2.shtml HTTP/1.1 Host: dozer.ironplanet.com:8763 HTTP/1.1 200 OK Date: Mon, 17 Feb 2003 19:22:29 GMT Server: Apache/2.0.44 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0210222112 Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=ISO-8859-1 5 hiya d Got to end! 0 --- I'd expect to see exactly the same output whether or not there's an internal redirect in the middle of the server-side processing of the .shtml file.
I can easily reproduce this on current code. The problem is that we're getting down to the chunk filter on an internal redirect. I'll attach a patch that fixes it for me in just a second. I'm not sure if the patch is complete, so I'm not ready to commit it.
Created attachment 4981 [details] patch file for adding the subrequest filter in internal_internal_redirect()
This patch appears to fix the problem for me.
Thanks for the quick feedback. After reviewing my patch some more I understand it well enough, so I've committed it to 2.1-dev. I'll propose that it be merged into the stable tree (2.0.45-dev). Thanks for using Apache, and thanks for your report!
*** Bug 16673 has been marked as a duplicate of this bug. ***
FYI, the fix for this problem has been merged into the stable tree for 2.0.45.