• 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
CocoaHTTPServer and missing Content-Length headers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CocoaHTTPServer and missing Content-Length headers


  • Subject: CocoaHTTPServer and missing Content-Length headers
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 27 Nov 2005 19:59:26 -0500


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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CocoaHTTPServer and missing Content-Length headers
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Re: POST with file and bytes written
  • Next by Date: Re: CocoaHTTPServer and missing Content-Length headers
  • Previous by thread: Re: POST with file and bytes written
  • Next by thread: Re: CocoaHTTPServer and missing Content-Length headers
  • Index(es):
    • Date
    • Thread