Bug #1276
awstats perl cgi doesn't work
| Status: | Fixed | Start: | ||
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | - | % Done: | 0% |
|
| Category: | mod_cgi | |||
| Target version: | 1.5.0 | |||
| Missing in 1.5.x: |
Description
Yeah, I know this sounds dumb, but the awstats perl program doesn't work through cgi in Lighttpd 1.5 (tested with revision 1878). Works fine under Lighttpd 1.4.
I wrote a short ruby cgi script and that works fine. I can see that perl is being executed, and that awstats is actually running (i put some debug code in there to test) but I just get an empty response. I get normal header, 200 code, empty body.
A couple of other people have had the same problems:
http://forum.lighttpd.net/topic/8283
I posted some debug output from my server there too.
I've tried disabling chunked encoding, and deflate compression. I've tested with and without ssl too.
History
Updated by zlib about 3 years ago
Hi,
I had a problem with awstats on lighty 1.5 a few months ago.
I posted a bug report to awstats as I wasn't sure if it was a problem with lighty or not.
http://sourceforge.net/tracker/index.php?func=detail&aid=1704820&group_id=13764&atid=113764
Basically, I found that $ENV{'CONTENT_LENGTH'} was set to -1 every time the script was executed. This causes the awstats script to crash at a certain point (detailed in my bug report).
Hope this helps.
Updated by john-leach about 3 years ago
Thanks, zlib, I've got awstats working now with your patch.
According to the CGI/1.1 specification, the webserver should only include this header if there is a message-body entity in the request. As I understand it, that header should only ever be empty or >= 1, never -1, so this looks to be a bug in Lighttpd really.
"The server MUST set this meta-variable if and only if the request is accompanied by a message-body entity"
and
"CONTENT_LENGTH = "" | 1*digit"
Updated by darix about 3 years ago
i tested this with lighttpd 1.4.15 and 1.5.r1857 and i cant reproduce your behavior with a simple ruby cgi script.
#!/usr/bin/ruby
require 'cgi'
print "Content-Type: text/plain\r\n\r\n"
c = CGI.new
print "CONTENT_LENGTH => #{c[:CONTENT_LENGTH]}\n" unless c[:CONTENT_LENGTH].empty?
print "ENV[CONTENT_LENGTH] => #{ENV['CONTENT_LENGTH']}\n" unless ENV['CONTENT_LENGTH'] or ENV['CONTENT_LENGTH'].empty?
print "END\n"
the output is just "END" for a simple GET request. even for a post request without attachment data it is the same:
$ curl -X POST -d 'test' -v http://localhost:8000/cgi-bin/env.rb * About to connect() to localhost port 8000 * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 8000 > POST /cgi-bin/env.rb HTTP/1.1 > User-Agent: curl/7.15.5 (x86_64-unknown-linux) libcurl/7.15.5 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0 > Host: localhost:8000 > Accept: */* > Content-Length: 4 > Content-Type: application/x-www-form-urlencoded > > testHTTP/1.1 200 OK < Transfer-Encoding: chunked < Content-Type: text/plain < Date: Mon, 30 Jul 2007 11:37:07 GMT < Server: lighttpd/1.4.15 END * Connection #0 to host localhost left intact * Closing connection #0 $ curl -X POST -d 'test' -v http://localhost/cgi-bin/env.rb * About to connect() to localhost port 80 * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 80 > POST /cgi-bin/env.rb HTTP/1.1 > User-Agent: curl/7.15.5 (x86_64-unknown-linux) libcurl/7.15.5 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0 > Host: localhost > Accept: */* > Content-Length: 4 > Content-Type: application/x-www-form-urlencoded > > testHTTP/1.1 200 OK < Content-Type: text/plain < Transfer-Encoding: chunked < Date: Mon, 30 Jul 2007 11:38:55 GMT < Server: lighttpd/1.5.x.svn.r1857 END * Connection #0 to host localhost left intact * Closing connection #0
and i cant reproduce it with a simple perl script either. so i would be happy to see a testcase. but atm i fail to see why it is a bug in lighttpd.
Updated by john-leach about 3 years ago
This is with a GET not a POST, sorry.
And you have a bug in your Ruby script, you're missing a ".nil?" on line 6:
#!/usr/bin/ruby
require 'cgi'
print "Content-Type: text/plain\r\n\r\n"
c = CGI.new
print "CONTENT_LENGTH => #{c[:CONTENT_LENGTH]}\n" unless c[:CONTENT_LENGTH].empty?
print "ENV[CONTENT_LENGTH] => #{ENV['CONTENT_LENGTH']}\n" unless ENV['CONTENT_LENGTH'].nil? or ENV['CONTENT_LENGTH'].empty?
print "END\n"
It looks like Ruby's CGI class is rfc compliant and doesn't accept the -1 value, but it's definitely there in the environment.
I can reproduce with this fixed script on a GET request.
Updated by jan about 3 years ago
- Status changed from New to Fixed
- Resolution set to fixed
Also available in: Atom