Ben Copsey

Added convenience constructors

@@ -21,6 +21,11 @@ @@ -21,6 +21,11 @@
21 return self; 21 return self;
22 } 22 }
23 23
  24 ++ (id)requestWithURL:(NSURL *)newURL
  25 +{
  26 + return [[[ASIFormDataRequest alloc] initWithURL:newURL] autorelease];
  27 +}
  28 +
24 - (void)dealloc 29 - (void)dealloc
25 { 30 {
26 [postData release]; 31 [postData release];
@@ -222,6 +222,9 @@ extern NSString* const NetworkRequestErrorDomain; @@ -222,6 +222,9 @@ extern NSString* const NetworkRequestErrorDomain;
222 // Should be an HTTP or HTTPS url, may include username and password if appropriate 222 // Should be an HTTP or HTTPS url, may include username and password if appropriate
223 - (id)initWithURL:(NSURL *)newURL; 223 - (id)initWithURL:(NSURL *)newURL;
224 224
  225 +// Convenience constructor
  226 ++ (id)requestWithURL:(NSURL *)newURL;
  227 +
225 #pragma mark setup request 228 #pragma mark setup request
226 229
227 // Add a custom header to the request 230 // Add a custom header to the request
@@ -104,6 +104,11 @@ static NSError *ASIUnableToCreateRequestError; @@ -104,6 +104,11 @@ static NSError *ASIUnableToCreateRequestError;
104 return self; 104 return self;
105 } 105 }
106 106
  107 ++ (id)requestWithURL:(NSURL *)newURL
  108 +{
  109 + return [[[ASIHTTPRequest alloc] initWithURL:newURL] autorelease];
  110 +}
  111 +
107 - (void)dealloc 112 - (void)dealloc
108 { 113 {
109 if (requestAuthentication) { 114 if (requestAuthentication) {
@@ -57,6 +57,9 @@ @@ -57,6 +57,9 @@
57 57
58 } 58 }
59 59
  60 +// Convenience constructor
  61 ++ (id)queue;
  62 +
60 // Used internally to manage HEAD requests when showAccurateProgress is YES, do not use! 63 // Used internally to manage HEAD requests when showAccurateProgress is YES, do not use!
61 - (void)addHEADOperation:(NSOperation *)operation; 64 - (void)addHEADOperation:(NSOperation *)operation;
62 65
@@ -40,6 +40,11 @@ @@ -40,6 +40,11 @@
40 return self; 40 return self;
41 } 41 }
42 42
  43 ++ (id)queue
  44 +{
  45 + return [[[ASINetworkQueue alloc] init] autorelease];
  46 +}
  47 +
43 - (void)dealloc 48 - (void)dealloc
44 { 49 {
45 //We need to clear the delegate on any requests that haven't got around to cleaning up yet, as otherwise they'll try to let us know if something goes wrong, and we'll be long gone by then 50 //We need to clear the delegate on any requests that haven't got around to cleaning up yet, as otherwise they'll try to let us know if something goes wrong, and we'll be long gone by then
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bigfile"]; 21 NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bigfile"];
22 [data writeToFile:path atomically:NO]; 22 [data writeToFile:path atomically:NO];
23 23
24 - ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; 24 + ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
25 25
26 NSDate *d = [NSDate date]; 26 NSDate *d = [NSDate date];
27 #if TARGET_OS_IPHONE 27 #if TARGET_OS_IPHONE
@@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
17 17
18 - (void)testBasicDownload 18 - (void)testBasicDownload
19 { 19 {
20 - NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com"] autorelease]; 20 + NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
21 - ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; 21 + ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
22 [request start]; 22 [request start];
23 NSString *html = [request responseString]; 23 NSString *html = [request responseString];
24 GHAssertNotNil(html,@"Basic synchronous request failed"); 24 GHAssertNotNil(html,@"Basic synchronous request failed");
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 complete = NO; 19 complete = NO;
20 progress = 0; 20 progress = 0;
21 21
22 - networkQueue = [[ASINetworkQueue alloc] init]; 22 + networkQueue = [[ASINetworkQueue queue] retain];
23 [networkQueue setDownloadProgressDelegate:self]; 23 [networkQueue setDownloadProgressDelegate:self];
24 [networkQueue setDelegate:self]; 24 [networkQueue setDelegate:self];
25 [networkQueue setShowAccurateProgress:NO]; 25 [networkQueue setShowAccurateProgress:NO];