URLSession data tasks always buffer the first 512 bytes

Originator:hamchapman
Number:rdar://31862557 Date Originated:27-04-2017
Status:Open Resolved:
Product:iOS + SDK Product Version:10.3.2
Classification: Reproducible:Yes
 
Summary:
URLSession data tasks always buffer the first 512 bytes before calling either dataTask:didReceiveResponse:completionHandler or dataTask:didReceiveData.

Steps to Reproduce:
Make a request to an endpoint that slowly streams some data and dataTask:didReceiveResponse:completionHandler and dataTask:didReceiveData will only be called once at least 512 bytes of data has been received.

Expected Results:
dataTask:didReceiveResponse:completionHandler gets called as soon as response headers are received and as soon as any data is received dataTask:didReceiveData gets called, unless some sort of flush interval is desired.

Actual Results:
Neither dataTask:didReceiveResponse:completionHandler or dataTask:didReceiveData gets called until at least 512 bytes of data are received.

Version:
10.3.2

Notes:
The current behaviour would be understandable as a default but there doesn’t seem to be any way to indicate that you want to be informed as soon as any data is received. 

Configuration:
MacBook Pro (Retina, 13-inch, Late 2013), 2.4 GHz Intel Core i5, 8 GB 1600 MHz DDR3 running iOS Simulator (10.3.2) with Xcode 8.3.2

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!