Bluehost.com Web Hosting $6.95

Keep-Alive and Content-Length problem

This is a discussion on Keep-Alive and Content-Length problem within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi! I hope this is the right newsgroup for this problem - I have searched all around the web and couldn'...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-19-2007
Anze
 
Posts: n/a
Default Keep-Alive and Content-Length problem

Hi!

I hope this is the right newsgroup for this problem - I have searched all
around the web and couldn't find the answer.

Short summary:
Apache + PHP on some servers return "Connection: Keep-Alive" header, but
without "Content-length: ..." header. Is this correct? How does client know
when the content ends?

Background:
I have a CMS which is (of course) locked by authentication. I'm using
PHPlib, which in turn uses PHP sessions. The whole system is well tested
over last 5 years or so and always worked flawlessly.
Lately there has been an occasional problem logging into the application.
The problem is server specific, but what is even weirder, it is also
browser-specific. For instance, I can always login without problems in
Konqueror, usually without problems in IE and... Firefox makes trouble.

Because of this I installed FF extension livehttpheaders and listened to
traffic between browser and server and compared it to a server where
everything worked. The only difference was Keep-Alive header:

GET /page.php HTTP/1.1
Host: www.domain.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2)
Gecko/20070208 Iceweasel/2.0.0.2 (Debian-2.0.0.2+dfsg-3)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,
text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Date: Mon, 19 Mar 2007 12:32:56 GMT
Server: Apache
Set-Cookie: PHPSESSID=bab0ea73140b093fa952396f22075a9c; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Keep-Alive: timeout=3, max=600
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-2

Then the client starts the next connection (for some image) and so on.

Now: there is Keep-Alive header, but no Content-Length. How does the browser
know when the content is finished?

Hope it makes sense... :)

Best,

Anze

Reply With Quote
  #2 (permalink)  
Old 03-19-2007
shimmyshack
 
Posts: n/a
Default Re: Keep-Alive and Content-Length problem

On 19 Mar, 13:05, Anze <anzen...@volja.net> wrote:
> Hi!
>
> I hope this is the right newsgroup for this problem - I have searched all
> around the web and couldn't find the answer.
>
> Short summary:
> Apache + PHP on some servers return "Connection: Keep-Alive" header, but
> without "Content-length: ..." header. Is this correct? How does client know
> when the content ends?
>
> Background:
> I have a CMS which is (of course) locked by authentication. I'm using
> PHPlib, which in turn uses PHP sessions. The whole system is well tested
> over last 5 years or so and always worked flawlessly.
> Lately there has been an occasional problem logging into the application.
> The problem is server specific, but what is even weirder, it is also
> browser-specific. For instance, I can always login without problems in
> Konqueror, usually without problems in IE and... Firefox makes trouble.
>
> Because of this I installed FF extension livehttpheaders and listened to
> traffic between browser and server and compared it to a server where
> everything worked. The only difference was Keep-Alive header:
>
> GET /page.php HTTP/1.1
> Host:www.domain.com
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2)
> Gecko/20070208 Iceweasel/2.0.0.2 (Debian-2.0.0.2+dfsg-3)
> Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,
> text/plain;q=0.8,image/png,*/*;q=0.5
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
>
> HTTP/1.x 200 OK
> Date: Mon, 19 Mar 2007 12:32:56 GMT
> Server: Apache
> Set-Cookie: PHPSESSID=bab0ea73140b093fa952396f22075a9c; path=/
> Expires: Thu, 19 Nov 1981 08:52:00 GMT
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
> pre-check=0
> Pragma: no-cache
> Keep-Alive: timeout=3, max=600
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/html; charset=ISO-8859-2
>
> Then the client starts the next connection (for some image) and so on.
>
> Now: there is Keep-Alive header, but no Content-Length. How does the browser
> know when the content is finished?
>
> Hope it makes sense... :)
>
> Best,
>
> Anze


does it have to know?
mostly they take a stream and render it if they can.
or use the javascript when instructed, even if corrupt, css etc...

keep live headers on and browse round the net, you will see very many
cases where the cl header is not set.

as for the content length header in your application, this is merely a
symptom of config, either in your server, or more probably your app,
so I'm suggesting that the header isn't the only difference.

Why not hack your app to send that header, test it, and if it works,
you've solved your issue. Personally I can't see /if the content-
length header _is_ the only difference/ that it would make a
significant difference to the functionality you're talking about - it
might though - I just can't see how at the mo.

Can you tell us more config diff between this and the working box(es)?

Reply With Quote
  #3 (permalink)  
Old 03-21-2007
Colin McKinnon
 
Posts: n/a
Default Re: Keep-Alive and Content-Length problem

Anze wrote:

Your question:

> Apache + PHP on some servers return "Connection: Keep-Alive" header, but
> without "Content-length: ..." header. Is this correct? How does client
> know when the content ends?
>


Your answer:

> Transfer-Encoding: chunked


Try Google for the specifics of chunked encoding.

C.
Reply With Quote
  #4 (permalink)  
Old 03-21-2007
Anze
 
Posts: n/a
Default Re: Keep-Alive and Content-Length problem


Thank you both for your answers!

Yes, chunked encoding is the answer... We live to learn. :)
Well, I'll just have to debug more.

Thank you again for clearing this up and happy coding!

Best,

Anze


> Your answer:
>
>> Transfer-Encoding: chunked

>
> Try Google for the specifics of chunked encoding.


Reply With Quote
  #5 (permalink)  
Old 03-21-2007
Anze
 
Posts: n/a
Default Re: Keep-Alive and Content-Length problem

>> Now: there is Keep-Alive header, but no Content-Length. How does the
>> browser know when the content is finished?

>
> does it have to know?
> mostly they take a stream and render it if they can.


Yes, they have to know - otherwise page rendering wouldn't be much stable.
Of course they try to render a page asap, but still... Coding a browser
that wouldn't know when a page ended would be unnecessarily much harder.

But this is solved through chunked encoding which I wasn't aware it existed.

Thank you for your answer!

Best,

Anze
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:30 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0