httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Hoyt <ben.h...@harvest.com>
Subject Re: [users@httpd] "Content-Length: 0" problem in GET request
Date Fri, 24 Mar 2006 03:41:47 GMT
Ugh! Just had the "duh!" moment. It was my CGI script's fault all along.

To get the POST/GET parameters, I was only parsing the QUERY_STRING 
environment variable if CONTENT_LENGTH was non-null, whereas I should 
have been parsing it if CONTENT_LENGTH was non-null *and* non-zero.

I didn't immediately connect that to the "Content-Length: 0" header 
(though it obviously is the same thing), because I knew my CGI script 
wasn't parsing the headers, Apache was. But of course Apache just 
converts that header to the CONTENT_LENGTH environment variable . . .

Thanks for reading anyway,
Ben


Ben Hoyt wrote:
> Hi all,
>
> I've got a problem with a "Content-Length: 0" header in GET requests. 
> I discovered it because some requests from newish mobile phone 
> browsers weren't working. Anyway, I captured the headers these phones 
> were sending in the GET request, and narrowed it down to them having a 
> "Content-Length: 0" header line.
>
> If the request has that "Content-Length: 0" header line (these mobiles 
> send it), Apache sends the wrong page---it always sends the home page 
> of the site. If the request doesn't have the Content-Length line (most 
> other browsers), Apache works fine---i.e., sends the correct page.
>
> So this works (try it with "telnet harvest.com 80"):
>
> GET /he HTTP/1.0
>
> but this doesn't (i.e., returns the site's main page instead of /he):
>
> GET /he HTTP/1.0
> Content-Length: 0
>
> (And it's not a HTTP 1.0 vs 1.1 issue---if I add a "Host: harvest.com" 
> line and change the GET to "GET /he HTTP/1.1" it still has the same 
> "Content-Length: 0" problem.)
>
> It seems like an Apache or Apache config issue, because I don't think 
> there's a problem including that "Content-Length: 0" header in the GET 
> request ... though I could be missing something obvious.
>
> Any pointers or info would be much appreciated. I'm using Apache 
> 2.0.47 under Win32 (WinXP SP2).
>
> Thanks heaps,
> Ben.
>

-- 
Ben Hoyt | ben.hoyt@harvest.com

Harvest Electronics | PO Box 446 | 10 Pragnell St | Masterton | New Zealand
http://www.harvest.com | Tel +64 6 370 1991 | Fax +64 6 370 1993



---------------------------------------------------------------------
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


Mime
View raw message