[PATCH] httpd: Support "Status: " header in CGI script
Denys Vlasenko
vda.linux at googlemail.com
Sat Aug 11 20:14:19 UTC 2007
On Wednesday 08 August 2007 13:09, Alex Landau wrote:
> Hi,
>
> The attached patch adds to httpd support for a Status header.
> This header (as per the CGI spec) is used by CGI scripts to ask the server
> to send an HTTP response different than 200. Why is it needed, and why the
> script can't send the "HTTP/1.0 302 Found" (or similar) by itself is beyond
> me...
> PHP (at least in CGI mode) sends "Status: 302" and the appropriate Location
> when running header('Location: something'). That was my motivation for the
> patch.
>
> Due to efficiency and space considerations, when httpd receives a "Status:
> xxx" header it sends "HTTP/1.0 xxx" without the textual code representation
> (e.g. "HTTP/1.0 302" instead of "HTTP/1.0 302 Found"). This works at least
> with Firefox 2.0.0.6 on Linux and IE 6 on, well..., Windows.
> If you think it's worth it, I can add proper message ("Found" etc.)
> handling.
I committed a bit simpler version:
/* "Status" header format is: "Status: 302 Redirected\r\n" */
if (buf_count >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
/* send "HTTP/1.0 " */
if (full_write(s, HTTP_200, 9) != 9)
break;
rbuf += 8; /* skip "Status: " */
count = buf_count - 8;
buf_count = -1; /* buffering off */
} else if (buf_count >= 4) {
Can you test whether it works for you?
--
vda
More information about the busybox
mailing list