Re: CocoaHTTPServer and missing Content-Length headers
Re: CocoaHTTPServer and missing Content-Length headers
- Subject: Re: CocoaHTTPServer and missing Content-Length headers
- From: Daniel Jalkut <email@hidden>
- Date: Sun, 27 Nov 2005 22:33:53 -0500
Aha - I think I found the answer. From RFC 2616:
In order to remain persistent, all messages on the connection MUST
have a self-defined message length (i.e., one not defined by closure
of the connection), as described in section 4.4.
So should the CFNetwork framework be doing this for me if the
connection is persistent? Or is it reasonable to assume that the
server code knows enough about the protocol to ensure this
requirement is met?
Daniel
On Nov 27, 2005, at 7:59 PM, Daniel Jalkut wrote:
A thread on Cocoa-Dev prompted me to examine the functionality of
the CocoaHTTPServer sample code.
It turns out that when the CocoaHTTPServer issues a stone cold
error, like "404" for file not found, it neglects to include any
headers or body whatsoever. I can't see in my quick look through
the HTTP RFC that this is wrong, but it seems problematic for
browsers including Firefox and Safari. When these browsers get the
single-line 404 response with no headers or body, they seem to hang
in anticipation of more data from the server.
In the context of an HTTP 1.1 persistent connection, is it
necessary to include a Content-Length header in order to cue the
client that the transaction is complete?
If it's not a requirement, what should CocoaHTTPServer be doing
instead to end the response without terminating the persistent
connection? I have found that by adding this line:
CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Content-
Length", @"0");
To code paths that generate content-free error responses. This
seems to sufficiently signal clients like Safari that they may
proceed with the next request.
I'm planning on using CocoaHTTPServer as a basis for one of my
projects, so I'd like to make sure I fix it in the best possible way.
Thanks for your advice!
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden