Closed GoogleCodeExporter closed 9 years ago
Added output flush - doesn't help:
------ begin --------
#!c:\usr\bin\perl.exe
$|=1;
print "Content-Length: 5\n";
print "Content-Type: text/plain\r\n\r\n";
print "hello";
------ end --------
Original comment by habazlam...@gmail.com
on 24 Jan 2011 at 2:52
Try setting CGI interpreter on the command line.
I suspect #!c:\usr\bin\perl.exe not working properly.
i.e. start mongoose as "mongoose -I c:/usr/bin/perl.exe"
Original comment by valenok
on 19 Feb 2011 at 11:57
start mongoose as "mongoose -I c:/usr/bin/perl.exe" -- done, the same behavior.
---- config begin ------
cgi_extensions .cgi,.pl,.php
# cgi_environment <value>
# put_delete_passwords_file <value>
cgi_interpreter C:\strawberry\perl\bin\perl.exe
# protect_uri <value>
# authentication_domain mydomain.com
# ssi_extensions .shtml,.shtm
access_log_file log/access.log
# ssl_chain_file <value>
enable_directory_listing yes
error_log_file log/error.log
# global_passwords_file <value>
# index_files index.html,index.htm,index.cgi
# enable_keep_alive no
# access_control_list <value>
# max_request_size 16384
# extra_mime_types <value>
listening_ports 80
document_root root
# ssl_certificate <value>
# num_threads 10
# run_as_user <value>
---- config end ------
What else? Just let me know, and I'll try to check it out immediately.
Original comment by habazlam...@gmail.com
on 19 Feb 2011 at 12:28
I noticed a similar problem and it was linked to using document_root, could you
check if it works without?
Original comment by dreal...@gmail.com
on 9 Mar 2011 at 9:27
Commented string "document_root root", behavior is the same:
Error 500: Internal Server Error
CGI program sent malformed HTTP headers: []
Original comment by habazlam...@gmail.com
on 9 Mar 2011 at 9:41
I'm seeing the same thing but only when my CGI scripts are in a separate
directory from the Mongoose executable. If the Perl files are in the same
folder as Mongoose, then they run as expected.
Original comment by redninja...@gmail.com
on 9 May 2011 at 9:25
When I used zend debugger for php-cgi, it always return this:
Error 500: Internal Server Error
CGI program sent malformed HTTP headers: []
Original comment by grant.li...@gmail.com
on 2 Jun 2011 at 2:42
I noticed the same problem when I tryed a tcc (tiny c) script. It was related
to the problem in the function spawn_process described in issue #243.
Original comment by federico...@gmail.com
on 2 Jun 2011 at 8:13
Original comment by valenok
on 22 Jun 2011 at 1:22
I suspect the format of newlines between Windows and Linux plays a role in
this problem. I had some perl scripts from Windows which I tried to run on
Ubuntu but was getting the "malformed header" message.
Here is how I fixed it:
Verify the shebang line points to a valid interpreter, e.g. #!/usr/bin/perl
Next convert the line endings to Linux by using dos2unix
Verify the scripts have execute permission
Now try running the script from the command line to make sure it works:
./test.cgi
Presto, my scripts were fixed, and I could get on with using this most
excellent web server.
There is a utility called hexdump which will display newlines by using hexdump
-C filename.cgi. On Windows they would be 0d 0a, on Linux 0a only. Most
editors are smart enough to hide the line endings on you, so it wasn't until I
tried running the script from the shell that I saw "missing perl interpreter
#!/usr/bin/perl^m"
Original comment by hh1...@gmail.com
on 26 Jun 2011 at 8:05
i also had this problem on windows.
newline format did help (some editors allow you to choose newline, i use
scite). without newline modification i get an output like this...
-----begin-----
Content-Type: text/plain
Hello, world
------end------
with newline modification in i get this...
-----begin-----
Hello, world
------end------
i also had to specify the location of doc root. otherwise only scripts at the
same location of mongoose.exe would work. i run mongoose like this...
C:\mongoose\mongoose-3.0.exe -C ".lua" -I "C:\mongoose\lua\lua5.1.exe" -r
"C:\mongoose\http"
Original comment by coppol...@gmail.com
on 8 Aug 2011 at 11:57
when i put the python script to the separate directory from the Mongoose
executable, it return the same thing.
Original comment by gewal...@gmail.com
on 10 Aug 2011 at 1:23
I'm getting the same issue on win7 with a php script (ASCII) with no newlines:
<?php echo('y');?>
Suddenly, even .php scripts which worked before return this. No errors are
logged in mongoose nor in php.
Original comment by cawo...@gmail.com
on 1 Sep 2011 at 9:44
OK, the reason was I uncommented the curl extension in PHP without actually
having the dll. It seems PHP ain't quite logging the errors the way I would
like nor is mongoose...
Original comment by cawo...@gmail.com
on 2 Sep 2011 at 9:36
it seems to occur when running scripts (perl in my case) from an aliased
folder. can anyone verify?
running mongoose v3.0 on windowsXP with activeperl.
Original comment by wilbyine...@gmail.com
on 12 Oct 2011 at 11:37
In my case:
C:\Program Files(x86)\mongoose\mongoose-3.0.exe -> NG
C:\Prog\mongoose\mongoose-3.0.exe -> OK
Original comment by i.am.1o...@gmail.com
on 19 Oct 2011 at 12:43
Specifying docroot should help (either in config or with the flag -r).
NOTICE: the docroot (and cgi_interpreter) should be with ABSOLUTE PATH to work
correctly.
Original comment by kiric...@gmail.com
on 12 Jan 2012 at 1:21
If the headers printed by CGI are incorrect, and path to document_root is set
as relative, we'll see empty [] brackets in the "malformed headers" error
message instead of the headers themselves. If document_root is set as absolute,
brackets indeed contain incorrect headers (that might help to find the error in
the CGI).
Original comment by habazlam...@gmail.com
on 14 Feb 2012 at 1:18
[deleted comment]
I'm having the same problem, but I can't seem to figure what mongoose expects
in the header. I think I'm doing it right, but mongoose consistently rejects
my script. Here's the script and the command-line output:
#!/home/andy/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"
print "<html><body>Hello World!</body></html>\r\n"
andy@z400:~/mongoose/ccweb> ./index.rb
HTTP/1.0 200 OK
Content-type: text/html
<html><body>Hello World!</body></html>
As far as I'm concerned, the output looks valid. Anyone?
-Andy
Original comment by ananon...@gmail.com
on 11 Apr 2012 at 6:23
Try to replace \r\n\r\n with \n\n
Original comment by edward.s...@gf.microolap.com
on 12 Apr 2012 at 4:57
Edward -- thanks for the comment. I tried your suggestion, but to no avail. I
am still having the same issue. I'll keep researching, however. Mongoose
coupled with Ruby and sqlite3 should make a powerful developer's combination.
Original comment by jm00000...@gmail.com
on 12 Apr 2012 at 4:54
I am having the same problem when using an .exe file as a CGI script! Sometimes
it returns a 500 error, sometimes it doesn't, but it just seems random. I
obviously can not set the Mongoose folder as the web root, as that would allow
people to execute the web server remotely. I don't really think absolute paths
would help either. It really is a shame, because Mongoose is the only web
server I've been able to get to work under Wine. However, it seems that these
problems persist in a native Windows environment, too. Does no one have a
solution to this problem?
Original comment by keanen.shaw@gmail.com
on 2 Jul 2012 at 2:09
Check comments #10, #17 and #18. Apart from those, there's also this:
http://code.google.com/p/mongoose/issues/detail?id=370
(issue 370)
From the look of it it applies to all 3.1 mongoose revisions till today, at
least. (Code review should quickly uncover whether your revision suffers from
the same.) When read_request() returns 0, you get that 'malformed' error line,
which would be (sort of) correct if read_request() worked correctly.
Original comment by ger.hobbelt
on 2 Jul 2012 at 6:56
Issue 364 has been merged into this issue.
Original comment by valenok
on 22 Sep 2012 at 2:10
There are several problems here. First, there is a newline problem, as
mentioned in comment 10.
I've run a hexdump of the script as saw this:
e:/perl/bin/perl.exe test\\hello.pl | hexdump -C
00000000 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 |Content-Length: |
00000010 35 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a |5..Content-Type:|
00000020 20 74 65 78 74 2f 70 6c 61 69 6e 0d 0d 0a 0d 0d | text/plain.....|
00000030 0a 68 65 6c 6c 6f |.hello|
00000036
Note that instead of 0d0a, perl prints 0d0d0a for "\r\n" -- this explains
malformed header problem.
0d0d0a is not a valid marker for the end of the header. When the same file is
called on Linux,
it is working as intended - 0d0a are produced.
e:/perl/bin/perl.exe -e 'print "\r\n"' | hexdump -C
00000000 0d 0d 0a
I don't know why windows version of Perl is doing that. I assume, Perl
interprets "\n" as OS specific line break, which is 0a on UNIX and 0d0a on
Windows. Therefore my suggestion is to use "\n" in your scripts instead of
"\r\n".
The second problem is with the paths.
I've submitted
https://github.com/valenok/mongoose/commit/5642dfcf3883f6d5ce6431c99fc9e6aa4177b
a28 to fix.
Please verify.
Original comment by valenok
on 22 Sep 2012 at 2:16
Original comment by valenok
on 22 Sep 2012 at 2:17
Original issue reported on code.google.com by
habazlam...@gmail.com
on 24 Jan 2011 at 2:48