You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Adam Woodworth <mi...@gmail.com> on 2007/12/19 19:06:31 UTC
Missing HTTP Headers
Hi,
I'm using a web stack consisting of Apache 2.2.6, mod_perl 2.0.3, and
libapreq 2.10 (from their svn branch), and I'm seeing a problem where
some headers are sometimes missing from the HTTP response.
Specifically, we are setting a couple cookies from our mod_perl
application, and about half the time the cookies show up in the Apache
response, and half the time they don't. I've tried using
Apache2::Cookie::new and Apache2::Cookie::bake to write the cookies
out, as well as doing it manually with $r->headers_out->add() and
$r->err_headers_out->add(), but the same problem exists in either
case.
Here is an example of the response headers I see when the cookies we
set come through, and when they don't come through. I've marked the
headers that differ between the two:
With Cookies:
Cache-Control: private, no-store, no-cache, max-age=0,
must-revalidate, proxy-revalidate
Connection: close
Date: Wed, 19 Dec 2007 16:42:37 GMT
Pragma: no-cache
Accept-Ranges: bytes
Server: Apache
Vary: *
Content-Type: text/html; charset=ISO-8859-1
Expires: Fri, 22 Jun 2007 17:16:24 GMT
Client-Date: Wed, 19 Dec 2007 17:27:34 GMT
Client-Peer: 192.168.1.71:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked <-- **missing from below**
P3P: CP="IDC DSP COR CUR PSA PSD IVA OUR BUS STA"
Set-Cookie: FOO=bar; path=/; domain=192.168.1.71; expires=Thu,
18-Dec-2008 17:27:09 GMT <-- **missing from below**
Set-Cookie: FAZ=baz; path=/; domain=192.168.1.71 <-- **missing from below**
Without Cookies:
Cache-Control: private, no-store, no-cache, max-age=0,
must-revalidate, proxy-revalidate
Connection: close
Date: Wed, 19 Dec 2007 16:42:35 GMT
Pragma: no-cache
Accept-Ranges: bytes
Server: Apache
Vary: *
Content-Length: 123434 <-- **missing from above**
Content-Type: text/html; charset=ISO-8859-1
Expires: Fri, 22 Jun 2007 17:16:24 GMT
Client-Date: Wed, 19 Dec 2007 17:27:32 GMT
Client-Peer: 192.168.1.71:80
Client-Response-Num: 1
P3P: CP="IDC DSP COR CUR PSA PSD IVA OUR BUS STA"
Has anyone ever seen this problem before, or can point me in the right
direction? It appears that somewhere in the web stack the headers are
sometimes just not making it all the way to the response...
Thanks!
Re: Missing HTTP Headers
Posted by Adam Woodworth <mi...@gmail.com>.
Thank you for the clarification, Geoff!
I've traced this missing cookie header issue down to a very strange
problem: it seems to be a timing issue somehow. If I put a usleep(1)
in our code at the start of our perl Response filter, the cookies are
no longer missing for each response. For that matter if I use
usleep(0) it works, so it seems that delaying the execution of our
code by a very tiny amount (enough for a function call to usleep())
seems to make the headers come out correctly, but I have no idea why
this would be happening. My first thought is some select() timeout
issue somewhere in the Apache stack but that doesn't really make
sense.
To be clear, any arbitrary header we add gets lost, not just cookies,
but I noticed it with the cookie headers.
Anyone have any idea about this timing issue?
Thanks
On Dec 19, 2007 4:14 PM, Geoffrey Young <ge...@modperlcookbook.org> wrote:
>
> > Client-Transfer-Encoding: chunked <-- **missing from below**
>
> > Content-Length: 123434 <-- **missing from above**
>
> you don't need a Content-Length header of your client uses a chunked
> transfer encoding, so these two are kinda mutually exclusive.
> fortunately, you also don't need to know that - these are both headers
> that apache sets for you when it generates the response.
>
> it doesn't address your cookie issue, but you don't need to worry about
> these headers in particular.
>
> --Geoff
>
Re: Missing HTTP Headers
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Client-Transfer-Encoding: chunked <-- **missing from below**
> Content-Length: 123434 <-- **missing from above**
you don't need a Content-Length header of your client uses a chunked
transfer encoding, so these two are kinda mutually exclusive.
fortunately, you also don't need to know that - these are both headers
that apache sets for you when it generates the response.
it doesn't address your cookie issue, but you don't need to worry about
these headers in particular.
--Geoff
Re: Missing HTTP Headers
Posted by Adam Woodworth <mi...@gmail.com>.
Yup, I'm directly hitting the application, there's nothing in between
my client and the server.
On Dec 19, 2007 1:39 PM, Torsten Foertsch <to...@gmx.net> wrote:
> On Wed 19 Dec 2007, Adam Woodworth wrote:
> > Content-Length: 123434 <-- **missing from above**
>
> Are you really sure you hit your application in these cases? If you don't set
> the Content-Length header. Maybe a cache in between does.
>
> Torsten
>
Re: Missing HTTP Headers
Posted by Torsten Foertsch <to...@gmx.net>.
On Wed 19 Dec 2007, Adam Woodworth wrote:
> Content-Length: 123434 <-- **missing from above**
Are you really sure you hit your application in these cases? If you don't set
the Content-Length header. Maybe a cache in between does.
Torsten