• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CocoaHTTPServer and missing Content-Length headers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: CocoaHTTPServer and missing Content-Length headers
      • From: Becky Willrich <email@hidden>
References: 
 >CocoaHTTPServer and missing Content-Length headers (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: CocoaHTTPServer and missing Content-Length headers
  • Next by Date: Re: Content Length always 0
  • Previous by thread: CocoaHTTPServer and missing Content-Length headers
  • Next by thread: Re: CocoaHTTPServer and missing Content-Length headers
  • Index(es):
    • Date
    • Thread