Note that there are some explanatory texts on larger screens.

plurals
  1. POphp and Content-Length header connection stall
    primarykey
    data
    text
    <p>I have a php website. Since I'm using template engine and I always do the html in "one-shot" I have the size of the html document upfront. So I decided to set Content-Length header for better performance. If I don't set it the document is transferred using chunked encoding.</p> <p>The php code for html output looks like this:</p> <pre><code>header('Accept-Ranges: none'); header('Content-Length: '.strlen($content)); echo $content; </code></pre> <p>I tested it under windows in Chrome, IE, Firefox and Safari - it works file. However Microsoft Bing bot (using bing webmaster tools) said that the website does not respond. I decided to investigate and here is what I found out:</p> <ul> <li>wget works fine on CentOS 5.x and CentOS 6.x</li> <li>elinks on CentOS 6.x works fine</li> <li>elinks on CentOS 5.x <strong>stalls</strong> (version elinks-0.11.1-6.el5_4.1)</li> </ul> <p>so elinks on Centos 5 was the only http client that I found which has problems accessing the site. However I don't know how to get debug information out of it.</p> <p>Questions:</p> <ol> <li>Can someone tell me how to get debug info out of elinks. Is it possible to have raw dup of http+headers? Or some kind of error log</li> <li>Any idea why stalling happens in one client and doesn't heppen in another?</li> <li>Well it's most probably the incorrect header "Content-Length" that's causing the problem because when I remove it it works fine in elinks and Bing. What could cause content lenght difference</li> <li>Any other http clients to test with?</li> </ol> <p>All tests are done on the same web server, the same php version, the same web page and with the same content. What I can think of is UTF-8 text file identifier (the few bytes in front of a text file that some browsers place)</p> <p>Here is a dump of headers with wget:</p> <pre><code>wget dev.site.com/ --server-response -O /dev/null --2013-11-09 01:32:37-- http://dev.site.com/ Resolving dev.site.com... 127.0.0.1 Connecting to dev.site.com|127.0.0.1|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Fri, 08 Nov 2013 23:32:37 GMT Server: Apache Set-Cookie: lng=en; expires=Wed, 07-May-2014 23:32:37 GMT; path=/; domain=dev.site.com Last-Modified: Fri, 08 Nov 2013 23:32:37 GMT Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Expires: 0 Set-Cookie: PHPSESSID=8a1e9b871474b882e1eef4ca0dfea0fc; expires=Thu, 06-Feb-2014 23:32:37 GMT; path=/ Content-Language: en Set-Cookie: hc=1518952; expires=Mon, 17-Nov-2036 00:38:00 GMT; path=/; domain=dev.site.com Accept-Ranges: none Content-Length: 16970 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 Length: 16970 (17K) [text/html] Saving to: “/dev/null” 100%[===================================================================================================================================================================================================&gt;] 16,970 --.-K/s in 0.1s 2013-11-09 01:32:37 (152 KB/s) - “/dev/null” saved [16970/16970] </code></pre> <p><strong>update:</strong></p> <p>I was able to reproduce the problem, but only on production server. One difference I notice between the working and non-working elinks is that non-working sends this header: Accept-Encoding: gzip</p> <p>Of course if it's gzipped the size will be different. zlib.output_compression is On on php.ini. I guess that could be the problem. Also output buffering is 4096. That's strange because most browsers use compression when available. I'll try again in a web browser.</p> <p>Yes browser (chrome) also asks for compression and gzip exists in response headers:</p> <pre><code>Content-Length: 15916 Content-Encoding: gzip </code></pre> <p>view source shows exactly 15916 bytes. Chrome has an option to show raw headers as well as parsed. What could be happening is that Chrome actually decompresses data before counting. Sounds strange but it's the only explanation why GUI web browsers work and some lower level clients don't</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload