开发者

NSURLRequest receives data too late

开发者 https://www.devze.com 2023-02-25 07:18 出处:网络
I\'m using a NSURLRequest to receive data from an Java Ser开发者_运维百科vlet. The Servlet is writing something to the outputstream immediately.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消