• 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: Reading HTTP headers (was Re: cfsockets vs OT)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading HTTP headers (was Re: cfsockets vs OT)


  • Subject: Re: Reading HTTP headers (was Re: cfsockets vs OT)
  • From: Larry Gerndt <email@hidden>
  • Date: Tue, 06 Jan 2004 22:42:55 -0800

Becky Willrich <email@hidden> wrote:

>>> This raises a question I've long had: in HTTP, what is the best way
>>> to read
>>> in the HTTP header? The only way that makes sense to me is to read
>>> one byte
>>> at a time until I see the header terminator, 0x0D0A0D0A, because
>>> there is no
>>> way of knowing how big the header is. Am I missing something?
>>
>> General technique is to read() big chunks and do your
>> protocol parsing from the buffer. You generally don't
>> want to make N system calls to read/write N bytes.
>
> What he said - read in a big chunk, scan over the bytes read, and then
> somehow save the excess bytes (which presumably are part of the body of
> the response). If you are reading byte by byte, that will definitely
> explain the performance hit moving from OT to BSD sockets - OT is
> probably doing the buffering for you.

I wasn't the original poster on that issue, but yes I will take your (and
the others') advice and avoid single-byte reads, until I adopt CFNetwork.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Reading HTTP headers (was Re: cfsockets vs OT)
  • Next by Date: sample code for SOCKS proxy support?
  • Previous by thread: Re: Reading HTTP headers (was Re: cfsockets vs OT)
  • Next by thread: sample code for SOCKS proxy support?
  • Index(es):
    • Date
    • Thread