NSURLRequest receives data too late
I'm using a NSURLRequest to receive data from an Java Ser开发者_运维百科vlet. The Servlet is writing something to the outputstream immediately.
NSURLRequest immediately receives the response connection:didReceiveResponse:
, but receiving the data lasts 15 - 20 seconds. (So that's the time between didReceiveResponse
and didReceiveData
). It looks like NSURLRequest is buffering the data and waits for more data.
How can I prevent the problem?
NSURLConnection use low level buffering to collect the bytes.
There is a difference between didReceiveResponse and didRecieveData - as there would be some proxying/data routing that might cause the delay.
In order to perform your metrics you should be recording the time between first didRecieveData and connectionDidFinishLoading and compare the time when you do same on your web-browser.
Hope this helps.
精彩评论