You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Bill Stoddard <bi...@wstoddard.com> on 2001/01/25 14:35:48 UTC

Funny stuff with content negotiation

Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
duplicate set of headers beginning with Connection: Keep-Alive.

Bill

HTTP/1.1 200 OK\r\n
Date: Thu, 25 Jan 2001 13:29:56 GMT\r\n
Server: Apache/2.0b1-dev (Win32)\r\n
Content-Location: index.html.en\r\n
Vary: negotiate,accept-language,accept-charset\r\n
TCN: choice\r\n
Last-Modified: Fri, 19 Jan 2001 21:47:54 GMT\r\n
ETag: "84057d40-54c-43b21680;364efb80"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 1356\r\n
Keep-Alive: 0"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 1356\r\n
\r\n
Connection: Keep-Alive\r\n
Content-Type: \r\n
Content-Length: 1356\r\n
Keep-Alive: 0"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 1356\r\n
\r\n
Connection: Keep-Alive\r\n
\r\n
Content-Language: en\r\n
\r\n


Re: Funny stuff with content negotiation

Posted by Bill Stoddard <bi...@wstoddard.com>.
Yep, this is definitely part of the problem.  I have to set this work aside for awhile (debugging
while playing Mr. Mom) and get back to it in a few hours.

Bill

>
> Not confirmed this yet but I think the problem is in ap_http_header_filter(), specifically with
the
> buff pointer. buff is allocated then h.buf is made to point to this storage. As we continue to add
> headers,, h.buf is pointed to different storage (as the array needs to grow), but then we
> terminate_headers on the original buff pointer and send it along.
>
> Bill
>
> > "Bill Stoddard" <bi...@wstoddard.com> writes:
> >
> > > Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of
> minutes.
> > > Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice
the
> > > duplicate set of headers beginning with Connection: Keep-Alive.
> >
> > The Content-Type header field is FUBAR:
> >
> > Breakpoint 4, form_header_field (h=0xbfffb918,
> >     fieldname=0x80ea996 "Content-Type",
> >     fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at
> http_protocol.c:1791
> > 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
> >
> > This explains at least part of the bogosity.
> >
> > Uh, oh... Expires is messed up too.
> >
> > Breakpoint 4, form_header_field (h=0xbfffb918, fieldname=0x80ea9e5 "Expires",
> >     fieldval=0x81585f4 "th: 1311\r\nConnection: close\r\nContent-Type: cept-Ranges:
> bytes\r\nContent-Length: 1311\r\nConnection: close\r\n\r\nContent-Language: en\r\n") at
> http_protocol.c:1791
> > 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
> > (gdb)
> >
> > Time to back up a bit :)
> >
> > Does anybody have a gdb macro to dump a table?
> > --
> > Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
> >        http://www.geocities.com/SiliconValley/Park/9289/
> >              Born in Roswell... married an alien...
> >
>


Re: Funny stuff with content negotiation

Posted by Bill Stoddard <bi...@wstoddard.com>.
Not confirmed this yet but I think the problem is in ap_http_header_filter(), specifically with the
buff pointer. buff is allocated then h.buf is made to point to this storage. As we continue to add
headers,, h.buf is pointed to different storage (as the array needs to grow), but then we
terminate_headers on the original buff pointer and send it along.

Bill

> "Bill Stoddard" <bi...@wstoddard.com> writes:
>
> > Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of
minutes.
> > Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> > duplicate set of headers beginning with Connection: Keep-Alive.
>
> The Content-Type header field is FUBAR:
>
> Breakpoint 4, form_header_field (h=0xbfffb918,
>     fieldname=0x80ea996 "Content-Type",
>     fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at
http_protocol.c:1791
> 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
>
> This explains at least part of the bogosity.
>
> Uh, oh... Expires is messed up too.
>
> Breakpoint 4, form_header_field (h=0xbfffb918, fieldname=0x80ea9e5 "Expires",
>     fieldval=0x81585f4 "th: 1311\r\nConnection: close\r\nContent-Type: cept-Ranges:
bytes\r\nContent-Length: 1311\r\nConnection: close\r\n\r\nContent-Language: en\r\n") at
http_protocol.c:1791
> 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
> (gdb)
>
> Time to back up a bit :)
>
> Does anybody have a gdb macro to dump a table?
> --
> Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
>        http://www.geocities.com/SiliconValley/Park/9289/
>              Born in Roswell... married an alien...
>


Re: Funny stuff with content negotiation

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Jeff Trawick wrote:
> 
> Jeff Trawick <tr...@bellsouth.net> writes:
> 
> > The Content-Type header field is FUBAR:
> >
> > Breakpoint 4, form_header_field (h=0xbfffb918,
> >     fieldname=0x80ea996 "Content-Type",
> >     fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at http_protocol.c:1791
> > 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
> >
> > This explains at least part of the bogosity.
> 
> The problem is that the buffer for headers is not large enough.  The
> allocation was moved to a point before where we call
> compute_header_len() on the table, so the len variable is way too
> small when we alloc the buffer.  As we later build the header we
> overlay the storage where the individual header fields lived, thus
> corrupting the table.
> 
> I'll start looking at a fix now (something other than getting a
> 10000-byte header buffer, which is what I'm doing now :) ).
> --
> Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
>        http://www.geocities.com/SiliconValley/Park/9289/
>              Born in Roswell... married an alien...

Yes - That what I have found...

A temp dirty
work_around:apache20@vtxclere:~/apache/httpd-2.0/modules/http > cvs diff
http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.277
diff -u -r1.277 http_protocol.c
--- http_protocol.c     2001/01/24 23:47:42     1.277
+++ http_protocol.c     2001/01/26 17:28:09
@@ -2482,7 +2482,7 @@
     /* Need to add a fudge factor so that the CRLF at the end of the
headers
      * and the basic http headers don't overflow this buffer.
      */
-    len += strlen(ap_get_server_version()) + 100;
+    len += strlen(ap_get_server_version()) + 1000;
     buff_start = buff = apr_pcalloc(r->pool, len);
     ap_basic_http_header(r, buff);
     buff +=
strlen(buff);                                                      
+++

Sure that on Monday someone will have fixed it cleanly :=)

Cheers

Jean-frederic

+++

Re: Funny stuff with content negotiation

Posted by Jeff Trawick <tr...@bellsouth.net>.
Jeff Trawick <tr...@bellsouth.net> writes:

> The Content-Type header field is FUBAR:
> 
> Breakpoint 4, form_header_field (h=0xbfffb918,
>     fieldname=0x80ea996 "Content-Type",
>     fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at http_protocol.c:1791
> 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL); 
> 
> This explains at least part of the bogosity.

The problem is that the buffer for headers is not large enough.  The
allocation was moved to a point before where we call
compute_header_len() on the table, so the len variable is way too
small when we alloc the buffer.  As we later build the header we
overlay the storage where the individual header fields lived, thus
corrupting the table.

I'll start looking at a fix now (something other than getting a
10000-byte header buffer, which is what I'm doing now :) ).
-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: Funny stuff with content negotiation

Posted by rb...@covalent.net.
> > Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> > Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> > duplicate set of headers beginning with Connection: Keep-Alive.
> 
> The Content-Type header field is FUBAR:
> 
> Breakpoint 4, form_header_field (h=0xbfffb918,
>     fieldname=0x80ea996 "Content-Type",
>     fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at http_protocol.c:1791
> 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL); 
> 
> This explains at least part of the bogosity.
> 
> Uh, oh... Expires is messed up too.
> 
> Breakpoint 4, form_header_field (h=0xbfffb918, fieldname=0x80ea9e5 "Expires",
>     fieldval=0x81585f4 "th: 1311\r\nConnection: close\r\nContent-Type: cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n\r\nContent-Language: en\r\n") at http_protocol.c:1791
> 1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
> (gdb)                                   
> 
> Time to back up a bit :)
> 
> Does anybody have a gdb macro to dump a table?

It's already in .gdbinit (./httpd-2.0/.gdbinit.  It's called dump_table.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: Funny stuff with content negotiation

Posted by Jeff Trawick <tr...@bellsouth.net>.
"Bill Stoddard" <bi...@wstoddard.com> writes:

> Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> duplicate set of headers beginning with Connection: Keep-Alive.

The Content-Type header field is FUBAR:

Breakpoint 4, form_header_field (h=0xbfffb918,
    fieldname=0x80ea996 "Content-Type",
    fieldval=0x81585d4 "cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n") at http_protocol.c:1791
1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL); 

This explains at least part of the bogosity.

Uh, oh... Expires is messed up too.

Breakpoint 4, form_header_field (h=0xbfffb918, fieldname=0x80ea9e5 "Expires",
    fieldval=0x81585f4 "th: 1311\r\nConnection: close\r\nContent-Type: cept-Ranges: bytes\r\nContent-Length: 1311\r\nConnection: close\r\n\r\nContent-Language: en\r\n") at http_protocol.c:1791
1791        headfield = apr_pstrcat(h->r->pool, fieldname, ": ", fieldval, CRLF, NULL);
(gdb)                                   

Time to back up a bit :)

Does anybody have a gdb macro to dump a table?
-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: Funny stuff with content negotiation

Posted by Jeff Trawick <tr...@bellsouth.net>.
jean-frederic clere <jf...@fujitsu-siemens.com> writes:

> Hi,
> 
> You get something like this:
> ++++
> Connection: Keep-Alive
> Content-Type: ntent-Length: 1311
> Keep-Alive: Accept-Ranges: bytes
> Content-Length: 1311

yeah, see related thread "[PATCH] allocate properly-sized buffer for
header" yesterday...

Thanks,

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

Re: Funny stuff with content negotiation

Posted by jean-frederic clere <jf...@fujitsu-siemens.com>.
Jeff Trawick wrote:
> 
> "Bill Stoddard" <bi...@wstoddard.com> writes:
> 
> > Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> > Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> > duplicate set of headers beginning with Connection: Keep-Alive.
> 
> no specific ideas here, but I'll start working on it; it should be a
> good learning experience after not playing in this area for many
> moons...
> 
> --
> Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
>        http://www.geocities.com/SiliconValley/Park/9289/
>              Born in Roswell... married an alien...
Hi,

You get something like this:
++++
Connection: Keep-Alive
Content-Type: ntent-Length: 1311
Keep-Alive: Accept-Ranges: bytes
Content-Length: 1311

Connection: Keep-Alive

Content-Language: en
Expires: Accept-Ranges: bytes
Content-Length: 1311

Connection: Keep-Alive
Content-Type: ntent-Length: 1311
Keep-Alive: Accept-Ranges: bytes
Content-Length: 1311

Connection: Keep-Alive

Content-Language: en


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
 <HEAD>
  <TITLE>Test Page for Apache Installation</TITLE>
 </HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red
(active) -->
 <BODY
++++

When I make telnet hostname port and "GET /" The page contents looks
better...

That is a point to start, and increase the request until the response
gets corrupted...

I hope it helps

Cheers

Jean-frederic

Re: Funny stuff with content negotiation

Posted by rb...@covalent.net.
On 25 Jan 2001, Jeff Trawick wrote:

> "Bill Stoddard" <bi...@wstoddard.com> writes:
> 
> > Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> > Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> > duplicate set of headers beginning with Connection: Keep-Alive.
> 
> no specific ideas here, but I'll start working on it; it should be a
> good learning experience after not playing in this area for many
> moons...  

If this started yesterday, please look at basic_http_header.  I changed it
yesterday to fix a bug I was seeing.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: Funny stuff with content negotiation

Posted by Jeff Trawick <tr...@bellsouth.net>.
"Bill Stoddard" <bi...@wstoddard.com> writes:

> Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> duplicate set of headers beginning with Connection: Keep-Alive.

no specific ideas here, but I'll start working on it; it should be a
good learning experience after not playing in this area for many
moons...  

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

Re: Funny stuff with content negotiation

Posted by James Sutherland <ja...@cam.ac.uk>.
On Thu, 25 Jan 2001, Greg Stein wrote:

> I've also seen duplication on an OPTIONS request. Haven't dug into it yet.

I noticed similar duplication on a HEAD request to that Australian site
someone mentioned here: strangely, some fields were missing and one
differed in case. In that case, the duplication started with a second 200
status code, then some (but not all) fields of the header.

Perhaps the fields missing from the second copy would point to where to
look: I'll dig up that transcript and see what the differences were. It
looked as if something was generating a header into the body section???

> Offhand, I have no idea on what is happending below. I'd guess something
> whacky with the header filter (e.g. not removing itself properly).

Something odd regurgitating part of the header might explain it... Very
odd, anyway!


James.


Re: Funny stuff with content negotiation

Posted by Greg Stein <gs...@lyra.org>.
I've also seen duplication on an OPTIONS request. Haven't dug into it yet.

Offhand, I have no idea on what is happending below. I'd guess something
whacky with the header filter (e.g. not removing itself properly).

Cheers,
-g

On Thu, Jan 25, 2001 at 08:35:48AM -0500, Bill Stoddard wrote:
> Looking into this now but I suspect Ryan, Greg or Jeff can id the problem in a couple of minutes.
> Send in a request to 127.0.0.1 and the negotiated content returned is index.html.en. Notice the
> duplicate set of headers beginning with Connection: Keep-Alive.
> 
> Bill
> 
> HTTP/1.1 200 OK\r\n
> Date: Thu, 25 Jan 2001 13:29:56 GMT\r\n
> Server: Apache/2.0b1-dev (Win32)\r\n
> Content-Location: index.html.en\r\n
> Vary: negotiate,accept-language,accept-charset\r\n
> TCN: choice\r\n
> Last-Modified: Fri, 19 Jan 2001 21:47:54 GMT\r\n
> ETag: "84057d40-54c-43b21680;364efb80"\r\n
> Accept-Ranges: bytes\r\n
> Content-Length: 1356\r\n
> Keep-Alive: 0"\r\n
> Accept-Ranges: bytes\r\n
> Content-Length: 1356\r\n
> \r\n
> Connection: Keep-Alive\r\n
> Content-Type: \r\n
> Content-Length: 1356\r\n
> Keep-Alive: 0"\r\n
> Accept-Ranges: bytes\r\n
> Content-Length: 1356\r\n
> \r\n
> Connection: Keep-Alive\r\n
> \r\n
> Content-Language: en\r\n
> \r\n

-- 
Greg Stein, http://www.lyra.org/