Elirudite / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

oneliner perl CGI script print "Location: http://localhost:8080/a.html\n\n" doesn't redirect #288

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. mkdir html cgi-bin
2. echo 'print "Location: http://localhost:8080/b.html\n\n"' > cgi-bin/b.pl 
3. echo '<html><body><h2>Hello World</h2></body></html>' > html/b.html
4. mongoose -r $PWD/html,/cgi-bin=$PWD/cgi-bin
5. in browser http://localhost:8080/cgi-bin/b.pl

What is the expected output? What do you see instead?
I expect to see "Hello world " But get instead
Error 500: Internal Server Error
CGI program sent malformed HTTP headers: []

What version of the product are you using? On what operating system?
version 3.0 on windows XP and archlinux.

Please provide any additional information below.
I have coded this in c but do get no redirection.
While if I do
main(int c, char *v[], char *envp[]){
printf("Content-Type: text/html\n\n<html><body>");
for(i =0 ; envp[i];i++) printf("%s<br />\n",envp[i]);
printf("</body></html>");
return 0;
}

I do get all environment variables displayed!
I have tried several variations on this theme but I never end up with the 
redirection executed

Original issue reported on code.google.com by renezgt...@gmail.com on 19 Oct 2011 at 2:01

GoogleCodeExporter commented 9 years ago
You need to set Status header, too:

echo 'print "Status: 302\nLocation: http://localhost:8080/b.html\n\n"' > 
cgi-bin/b.pl 

Also, I've submitted a change that sets code 302 automatically if Location 
header is set in CGI reply:
https://code.google.com/p/mongoose/source/detail?r=544f09214e83fa120d611d7cc1fbe
be8f8a611b9

Original comment by valenok on 6 Nov 2011 at 10:25