我使用NSURLConnection的下載文件。(我基本上使用JGDownload Accelerator)問題與NSURLConnection的和服務器響應
我的問題是,當我嘗試在一個特定的服務器上下載文件時,由服務器提供的響應是各不相同,給了我像下面
Printing description of headers:
{
"Accept-Ranges" = bytes;
"Cache-Control" = "max-age=687749";
Connection = "keep-alive";
"Content-Length" = 35617808;
"Content-Type" = "video/mp4";
Date = "Fri, 11 Sep 2015 07:21:59 GMT";
Etag = "\"ee90ce32a16fc115d0799d686e5fe1b4\"";
Expires = "Sat, 19 Sep 2015 06:24:28 GMT";
"Keep-Alive" = "timeout=20";
"Last-Modified" = "Wed, 09 Sep 2015 13:41:37 GMT";
Server = ucdn;
"X-Timestamp" = "1441806096.99264";
"X-Ureq-ID" = "PYMqMNZBGw7LI3xeAHCTQwJs2FvO0y0xuG3+g5B0KcBzTv1v4kTfwCzHQYgrBEGSJQ0tBMG5L+srffrjBfio1R1ChR+wABEHY92PCg==";
"X-VHostId" = "10000, 200000";
}
{
"Cache-Control" = "max-age=687430";
Connection = "keep-alive";
"Content-Length" = 1;
"Content-Range" = "bytes 0-0/35617808";
"Content-Type" = "video/mp4";
Date = "Fri, 11 Sep 2015 07:27:18 GMT";
Etag = "\"ee90ce32a16fc115d0799d686e5fe1b4\"";
Expires = "Sat, 19 Sep 2015 06:24:28 GMT";
"Keep-Alive" = "timeout=20";
"Last-Modified" = "Wed, 09 Sep 2015 13:41:37 GMT";
Server = ucdn;
"X-Timestamp" = "1441806096.99264";
"X-Ureq-ID" = "PYMqMNZBGw7LI3xeAHCTQwJs2FvO0y0xuG3+g5B0KcBzTv1v4kTfwCzHQYgrBEGSJQ0tBMG5L+srffrjBfio1R1ChR+wABEHY92PCg==";
"X-VHostId" = "10000, 710000";
}
基本的尊重是content-length
鍵在第一個它提供適當的值,並在第二個它是錯誤的,不同的頭回應,我得到了約30延遲 - 40秒。
有什麼辦法可以避免這種延遲? 或任何解決方法,使響應快我的意思是服務器提供的數據在1到2秒,但回調方法提供數據晚
爲請求/響應時間我使用Charles應用程序。 我發現它的結果是HERE
你可以發佈請求標頭嗎? – KudoCC
我按照以下方式創建我的請求:NSMutableURLRequest * newRequest = request.mutableCopy; [newRequest setTimeoutInterval:10]; [newRequest setHTTPMethod:@「HEAD」];'沒有頭只'HTTPmethod'和'TimeoutInterval'在請求中設置 –