Accepting selected projects for Q2 2024 Check availability →
SERVER 02SYSTEM ONLINELAST SYNC: 03:17:44RSS 2.0 — ONLINE
HALF ASSEDTECHNICAL NOTES_
EST. 1999ISSUE 04.2BEST VIEWED AT 1024 × 768
TECHNICAL NOTES / TECHNICAL NOTES / HTTP / RECORD e28de0
[HTTP]NOTE

HTTP/1.1 connections and response lengths

POSTED: 18.11.1999AUTHOR: ADMIN2 MIN READCOMMENTS: 0

HTTP/1.1 normally allows a connection to remain open for another request. This saves repeated connection setup, but it means that the client cannot always use the end of the connection to identify the end of a page.

Make the body length clear

A response with a body can delimit it with an accurate Content-Length or, where appropriate for HTTP/1.1, chunked transfer coding. A response that relies on closing the connection cannot reuse that connection afterwards. Some responses, including responses to HEAD, have no message body; a server must apply the protocol’s rules rather than simply reading until a blank line or socket closure.

Leave framing to the web server

A CGI program should use its server’s documented output interface rather than constructing HTTP chunks itself. If it supplies Content-Length, the value must describe the bytes actually sent, including any output added by the application. Do not calculate it from a character count and then change the encoding or body. Test short, empty and error responses as well as the usual page.

Distinguish an idle connection from a slow request

A keep-alive timeout limits how long the server waits for another request; it is not the same as the permitted running time of an application. On a busy server, inspect worker usage before increasing it. Keep-alive changes should be checked with several requests on one connection and with HTTP/1.0 clients, not judged from a single successful browser load.

DIAGNOSTIC CHECK

If a page hangs only after another request, inspect the response boundaries and headers. Keep the raw exchange with the test result so the next operator can reproduce it.

References

RFC 2616: HTTP/1.1, sections 4.4 and 8.1