3

I am uses NSURLConnection to download files.(Basically I use JGDownload Accelerator)

My issue is when I try to download files at one particular server, response provided by server is vary and gives me different header responses like below

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";
}

Basic deference is the content-length key as in first one it provide proper value and in second one it is wrong and where I got delay around 30 - 40 seconds.

Is there any way I can avoid that delay? Or any workaround to make response fast I means server provides data with in 1 to 2 seconds but the callback method provides data late

for the request / response time I use Charles application. Results I found by it is HERE

Pablo A.
  • 2,042
  • 1
  • 17
  • 27
The iOSDev
  • 5,237
  • 7
  • 41
  • 78
  • Can you post the request headers ? – KudoCC Sep 16 '15 at 09:46
  • I create my request as follow `NSMutableURLRequest *newRequest = request.mutableCopy; [newRequest setTimeoutInterval:10]; [newRequest setHTTPMethod:@"HEAD"];` no header only `HTTPmethod` and `TimeoutInterval` is set in request – The iOSDev Sep 16 '15 at 09:54

2 Answers2

0

Looks like a problem within the webservice itself.

It is possible the service gets the data itself from a different service and passes them on. If the other service don't accept repeating connections from a client within a predefined time spawn (Retry-After Header).

Helge Becker
  • 3,219
  • 1
  • 20
  • 33
  • I also tried to skip this header request and directly requesting file download to start download but no luck delay is same as before don't able to find out any workaround to minimize the delay :( – The iOSDev Sep 21 '15 at 13:17
0

I have tried all the possible ways to reduce the time delay but it seems that there is no way available using NSURLConnection. So we have requested for the Apple Engineer Support for this issue and will get some response from them in while.

Till then there is no other way to avoid this delay due to wrong header information from server.

I will update here if I get any response from Apple.

The iOSDev
  • 5,237
  • 7
  • 41
  • 78