Ticket #1276 (closed defect: fixed)

Opened 10 months ago

Last modified 4 months ago

awstats perl cgi doesn't work

Reported by: john-leach Assigned to: jan
Priority: normal Milestone: 1.5.0
Component: mod_cgi Version: 1.5.x-svn
Severity: normal Keywords: MESSAGE
Cc: Montevideo Blocking:
Need Feedback: 0

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.

Attachments

MerryChristmasMyFrriendRedHeartCand.gif (64.0 kB) - added by anonymous on 01/01/2008 06:44:46 AM.

Change History

07/30/2007 10:58:42 AM changed by zlib

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.

07/30/2007 11:15:02 AM changed by john-leach

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"

http://www.ietf.org/rfc/rfc3875

07/30/2007 11:49:14 AM changed by darix

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.

07/30/2007 12:24:20 PM changed by john-leach

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.

08/15/2007 11:40:30 AM changed by jan

  • status changed from new to closed.
  • resolution set to fixed.

fixed in [1914] and [1915]

01/01/2008 06:44:46 AM changed by anonymous

  • attachment MerryChristmasMyFrriendRedHeartCand.gif added.

01/26/2008 11:25:46 AM changed by Utisrerie

  • cc set to Montevideo.
  • keywords changed from cgi perl awstats to MESSAGE.

Hi all! amusing--priced-hat worck new look senks void akaaunting G'incessantly


Add/Change #1276 (awstats perl cgi doesn't work)




Change Properties
Action