• 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: Proxies, Bytes, and CFNetwork
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proxies, Bytes, and CFNetwork


  • Subject: Re: Proxies, Bytes, and CFNetwork
  • From: Becky Willrich <email@hidden>
  • Date: Fri, 11 Apr 2003 10:39:00 -0700

First off, you should not use CFHTTPReadStreamSetProxy() unless you need compatibility to 10.1; starting with 10.2, you should call CFReadStreamSetProperty() instead, passing kCFStreamPropertyHTTPProxy for the property name; it's value should be a dictionary with the keys and values as described in the header file. If you simply want to use the proxies defined on the system, get the proxy dictionary from the SystemConfiguration framework and pass it as the value; CFNetwork will pick it apart correctly. I know the header doesn't document that CFHTTPReadStreamSetProxy() has been obsoleted; mea culpa. You try and scrub the headers, but something always gets through....

As for when you can get the response header - you're guaranteed the response header is there when the first byte arrives, or at the end of the stream if the response is empty (no data). One caveat - even if the response has some data bytes, the response header may not be complete when the first byte arrives - some (relatively rare) servers include additional headers at the end of the data transmission; if you're talking to such a server, you can't get the complete header until the stream reports it has reached the end.

To apply authentication information, you are right that you need to call CFHTTPMessageAddAuthentication. You can actually call this at any time if you intend to use the Basic authentication scheme, but Digest authentication, for instance, needs some of the values from the 401/407 failure response to be able to construct the correct request. Digest is also considerably more secure than Basic, so unless you are sure that the server requires authentication, but does not support Digest, you should wait until you receive the 401/407.

If you get both a 407 and a 401, you can call CFHTTPMessageAddAuthentication again with the same request, just make sure you pass the right value for the forProxy flag with the right response (i.e. when you get a 407 back, make sure forProxy is TRUE, and when you get a 401, make sure forProxy is FALSE).

Finally, there is no way to know for sure how many bytes are coming, because HTTP does not guarantee that that's known in advance. However, you can look at the Content-Length header field from the response header - if it's set, it will contain the number of bytes expected.

Hope that helps,
REW
_______________________________________________
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: Rendezvous Name
  • Next by Date: Re: Rendezvous Name
  • Previous by thread: Proxies, Bytes, and CFNetwork
  • Next by thread: RE: Proxies, Bytes, and CFNetwork
  • Index(es):
    • Date
    • Thread