Re: NSURLConnection callbacks in the presence of errors
Re: NSURLConnection callbacks in the presence of errors
- Subject: Re: NSURLConnection callbacks in the presence of errors
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Fri, 10 Jan 2014 12:07:16 +0000
On 9 Jan 2014, at 21:54, Jens Alfke <email@hidden> wrote:
> Oh, I just remembered — if the response is chunked, NSURLConnection will buffer up the _entire_ response before decoding it and sending it to your delegate.
Most of Jens's comments are spot on, but this is wrong, at least on modern systems. I tested this with a test app running in the iOS 7 simulator and "nc" running on my Mac. Once "nc" received the request, I sent 16 byte chunks to the client. The client buffered about 512 bytes of data before delivering anything to the delegate. After that, each 16 byte chunk was delivered to the delegate as it arrived at the client. See the transcript below.
> This is a bug, and I filed a bug report a year or two ago.
Do you have that bug number handy? As always, there may be other complicating factors.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
---------------------------------------------------------------------------
In the transcript following:
o Lines prefixed by "<" are received by the server.
o Lines prefixed by ">" are sent by the server.
o Lines prefixed by "#" are comments.
o Lines prefixed by "+" are printed by the client.
$ nc -c -l 12345
< GET / HTTP/1.1
< Host: localhost:12345
< Connection: keep-alive
< Accept-Encoding: gzip, deflate
< User-Agent: xxx/1.0 CFNetwork/672.0.8 Darwin/13.0.2
< Accept-Language: en-us
< Accept: */*
<
> HTTP/1.1 200 OK
> Date: Fri, 10 Jan 2014 09:36:50 GMT
> Transfer-Encoding: chunked
>
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
> 10
> 0123456789abcdef
# At this point the client received its first data delegate callback.
+ 2014-01-10 10:48:32.713 xxx[51268:70b] data 512
# And from now on, each chunk results in an immediate data delegate callback.
> 10
> 0123456789abcdef
+ 2014-01-10 10:48:37.825 xxx[51268:70b] data 16
# And so on.
> 10
> 0123456789abcdef
+ 2014-01-10 10:48:37.825 xxx[51268:70b] data 16
---------------------------------------------------------------------------
_______________________________________________
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