You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jose Adriano Baltieri <ja...@unimep.br> on 2006/07/28 21:42:33 UTC
[users@httpd] Error when issuing a 302 from a CGI
I have a tiny CGI program written in C that's like this :
# include <stdio.h>
main()
{
printf("HTTP/1.1 302 Found\n");
printf("Location: http://www.unimep.br\n\n");
}
Running it at the prompt, it will print of course :
HTTP/1.1 302 Found
Location: http://www.unimep.br
However, when I run it from the browser I'll receive an "Internal Server
Error".
Error.log tells me this :
malformed header from script. Bad header=HTTP/1.1 302 Found: TEST080.exe
What's wrong ?
--
Obrigado,
------------------------------------------------------------------------------
Jose Adriano Baltieri - Analista de Sistemas
DTI - CENTRO - UNIMEP - Universidade Metodista de Piracicaba
PIRACICABA - SP - Brasil - Fone : (19) 3124-1858
------------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Error when issuing a 302 from a CGI
Posted by Nick Kew <ni...@webthing.com>.
On Friday 28 July 2006 21:34, Joshua Slive wrote:
> > Rename the CGI script to nph-something -- this will tell mod_cgi to treat
> > the script as one with non-parseable headers (and subsequently leaves the
> > response code alone to do with as you wish).
Whilst feasible, that's fragile and requires more work than normal CGI.
> This advice will probably work, but the better advice is to replace
> the first line with
> Status: 302 Found
Yep.
But you can simply omit it altogether, as it is implied by the CGI
Location header.
> CGI scripts don't emit the status line, but they can tell the server
> to send a particular status using the Status header. See the CGI
> spec.
Exactly. Don't confuse CGI "special" headers with HTTP headers.
And don't confuse the HTTP status code with a header.
--
Nick Kew
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Error when issuing a 302 from a CGI
Posted by Jose Adriano Baltieri <ja...@unimep.br>.
Joshua Slive wrote:
> On 7/28/06, Eike Frost <ei...@kefro.st> wrote:
>> Hi,
>>
>> On Friday 28 July 2006 21:42, Jose Adriano Baltieri wrote:
>> > I have a tiny CGI program written in C that's like this :
>> (...)
>> > HTTP/1.1 302 Found
>> > Location: http://www.unimep.br
>> >
>> > However, when I run it from the browser I'll receive an "Internal
>> Server
>> > Error".
>>
>> Rename the CGI script to nph-something -- this will tell mod_cgi to
>> treat the
>> script as one with non-parseable headers (and subsequently leaves the
>> response code alone to do with as you wish).
>
> This advice will probably work, but the better advice is to replace
> the first line with
> Status: 302 Found
> CGI scripts don't emit the status line, but they can tell the server
> to send a particular status using the Status header. See the CGI
> spec.
Hi Joshua !
Your suggestion DOES fixes it. I applied it and now it's working OK !
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
--
Obrigado,
------------------------------------------------------------------------------
Jose Adriano Baltieri - Analista de Sistemas
DTI - CENTRO - UNIMEP - Universidade Metodista de Piracicaba
PIRACICABA - SP - Brasil - Fone : (19) 3124-1858
------------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Error when issuing a 302 from a CGI
Posted by Joshua Slive <jo...@slive.ca>.
On 7/28/06, Eike Frost <ei...@kefro.st> wrote:
> Hi,
>
> On Friday 28 July 2006 21:42, Jose Adriano Baltieri wrote:
> > I have a tiny CGI program written in C that's like this :
> (...)
> > HTTP/1.1 302 Found
> > Location: http://www.unimep.br
> >
> > However, when I run it from the browser I'll receive an "Internal Server
> > Error".
>
> Rename the CGI script to nph-something -- this will tell mod_cgi to treat the
> script as one with non-parseable headers (and subsequently leaves the
> response code alone to do with as you wish).
This advice will probably work, but the better advice is to replace
the first line with
Status: 302 Found
CGI scripts don't emit the status line, but they can tell the server
to send a particular status using the Status header. See the CGI
spec.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Error when issuing a 302 from a CGI
Posted by Eike Frost <ei...@kefro.st>.
Hi,
On Friday 28 July 2006 21:42, Jose Adriano Baltieri wrote:
> I have a tiny CGI program written in C that's like this :
(...)
> HTTP/1.1 302 Found
> Location: http://www.unimep.br
>
> However, when I run it from the browser I'll receive an "Internal Server
> Error".
Rename the CGI script to nph-something -- this will tell mod_cgi to treat the
script as one with non-parseable headers (and subsequently leaves the
response code alone to do with as you wish).
--Eike
Re: [users@httpd] Error when issuing a 302 from a CGI
Posted by Jerry McAllister <je...@clunix.cl.msu.edu>.
>
> I have a tiny CGI program written in C that's like this :
>
> # include <stdio.h>
> main()
> {
> printf("HTTP/1.1 302 Found\n");
> printf("Location: http://www.unimep.br\n\n");
> }
>
> Running it at the prompt, it will print of course :
>
> HTTP/1.1 302 Found
> Location: http://www.unimep.br
>
>
> However, when I run it from the browser I'll receive an "Internal Server
> Error".
>
> Error.log tells me this :
>
> malformed header from script. Bad header=HTTP/1.1 302 Found: TEST080.exe
>
> What's wrong ?
I may be wrong, but I think your double \n\n needs to come in the
first line with the 'HTTP'
////jerry
>
> --
> Obrigado,
> ------------------------------------------------------------------------------
> Jose Adriano Baltieri - Analista de Sistemas
> DTI - CENTRO - UNIMEP - Universidade Metodista de Piracicaba
> PIRACICABA - SP - Brasil - Fone : (19) 3124-1858
> ------------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org