0

I am writing a utility that allows users to download large files from my server. I need the user to have the flexibility to pause and resume a download request through a button click. I am using ASIHTTPRequest library, however it doesn;t provide any API to pause a request. (There are routines to resume a download request). Is canceling a download request only way to pause a request.

Thanks

Bhumik
  • 1
  • 2
    http://groups.google.com/group/asihttprequest/browse_thread/thread/a6f89a9fb0587874/7191f5bd2048d942?lnk=gst&q=pausing#7191f5bd2048d942 – Marek Sebera Sep 06 '11 at 17:18
  • possible duplicate of [About download file using ASIHttpRequest](http://stackoverflow.com/questions/3341658/about-download-file-using-asihttprequest) – PengOne Sep 06 '11 at 17:21

2 Answers2

0

Most servers support the HTTP range header. You can use this to specify the offset from which you’re requesting on resume.

gcbrueckmann
  • 2,413
  • 18
  • 10
0

There is no direct way to pause downloading. This can be achieved using range header of HTTP protocol.

Read here for details....

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16

Setting range property in request header will do. For knowing how to set request header in Library you are using read the documentation.

following would be the way parameter to pass in range.

NSString* range = @"bytes=";
range = [range stringByAppendingString:[[NSNumber numberWithInt:offset] stringValue]];
range = [range stringByAppendingString:@"-"];
[request setValue:range forHTTPHeaderField:@"Range"];

Use NSMutableRequest and NSURLConnection if you want to use abuve code

Mohammad
  • 1,636
  • 1
  • 13
  • 17