You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marc Slemko <ma...@znep.com> on 2001/08/27 00:53:59 UTC

odd content length goings on

if I have a CGI that generates less than 8k of output, the content length
doesn't get set.

If it generates between 8k and 32k or something like that, it does.

is this a known bug?


Re: odd content length goings on

Posted by Marc Slemko <ma...@znep.com>.
On 27 Aug 2001, Jeff Trawick wrote:

> Marc Slemko <ma...@znep.com> writes:
> 
> > Erm... why would we be unable to read the data?
> > 
> > I have the exact same CGI.  If I have it output, for example, 6k of data
> > there is never a content-length.  If I have it output, for example, 10k of 
> > data, there is.
> 
> is there some buffering or pausing going on which affects the
> length=6k case?  I get a content-length for lengths up to 32K or so.

What platform?  I'm FreeBSD / prefork.  

As I said, ap_set_content_length gets called, but it just doesn't end up being sent.

marcs@deathbed:~$ GET -e -d http://localhost:8080/~marcs/tests/anylength.cgi?length=8166
Connection: close
Date: Mon, 27 Aug 2001 16:39:49 GMT
Server: Apache/2.0.25-dev (Unix)
Content-Type: text/html; charset=ISO-8859-1

marcs@deathbed:~$ GET -e -d http://localhost:8080/~marcs/tests/anylength.cgi?length=8167
Connection: close
Date: Mon, 27 Aug 2001 16:39:54 GMT
Server: Apache/2.0.25-dev (Unix)
Content-Length: 8167
Content-Type: text/html; charset=ISO-8859-1

marcs@deathbed:~$ GET -e -d http://localhost:8080/~marcs/tests/anylength.cgi?length=1   
Connection: close
Date: Mon, 27 Aug 2001 16:40:46 GMT
Server: Apache/2.0.25-dev (Unix)
Content-Type: text/html; charset=ISO-8859-1


Hrmph.  The truss of a CGI request looks pretty scary...


Re: odd content length goings on

Posted by Jeff Trawick <tr...@attglobal.net>.
Marc Slemko <ma...@znep.com> writes:

> Erm... why would we be unable to read the data?
> 
> I have the exact same CGI.  If I have it output, for example, 6k of data
> there is never a content-length.  If I have it output, for example, 10k of 
> data, there is.

is there some buffering or pausing going on which affects the
length=6k case?  I get a content-length for lengths up to 32K or so.

---------anylength.pl---------
#!/usr/local/bin/perl -w

BEGIN
{
  use CGI::Carp qw(fatalsToBrowser);
}

use strict;

use CGI;

my $q = new CGI;
my $offset = $q->param('length');
my $i;

if (!$offset)
{
  die "Yo!  I need an offset!";
}

print "Content-type: text/html\n\n";

$i = 0;
while ($offset > 0)
{
  if (($i % 50) eq 0)
  {
    print "\n";
  }
  else
  {
    print "1";
  }
  ++$i;
  --$offset;
}
--------------------------

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: odd content length goings on

Posted by Marc Slemko <ma...@znep.com>.
On Sun, 26 Aug 2001, Ryan Bloom wrote:

> On Sunday 26 August 2001 15:53, Marc Slemko wrote:
> > if I have a CGI that generates less than 8k of output, the content length
> > doesn't get set.
> >
> > If it generates between 8k and 32k or something like that, it does.
> >
> > is this a known bug?
> 
> Why are you assuming this is a bug?  It looks like in the first request, we are unable
> to read the data for some reason, but the second request, when the content-length
> filter tries to read the CGI data, it is able to.
> 
> The C-L filter tries to determine how much data is there, if it can't read everything,
> then it just passes to the next filter, and we use either chunking, or we close the
> connection after the request.

Erm... why would we be unable to read the data?

I have the exact same CGI.  If I have it output, for example, 6k of data
there is never a content-length.  If I have it output, for example, 10k of 
data, there is.

Sure, once you go _above_ 32k (erm.. 4*AP_MIN_BYTES_TO_WRITE I think) 
then it won't buffer.  But that isn't the issue.  The _smaller_ response
isn't getting the content-length added.  The content length filter is
calling ap_set_content_length with the right value, but it never 
makes it to the client... don't know what is going on there.


Re: odd content length goings on

Posted by Ryan Bloom <rb...@covalent.net>.
On Sunday 26 August 2001 15:53, Marc Slemko wrote:
> if I have a CGI that generates less than 8k of output, the content length
> doesn't get set.
>
> If it generates between 8k and 32k or something like that, it does.
>
> is this a known bug?

Why are you assuming this is a bug?  It looks like in the first request, we are unable
to read the data for some reason, but the second request, when the content-length
filter tries to read the CGI data, it is able to.

The C-L filter tries to determine how much data is there, if it can't read everything,
then it just passes to the next filter, and we use either chunking, or we close the
connection after the request.

Ryan

______________________________________________________________
Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------