Added new method to set file data on ASIFormDataRequest with an NSData object
Set content-length for request when setting postBody Tweak tests
Showing
9 changed files
with
76 additions
and
36 deletions
| @@ -23,7 +23,10 @@ | @@ -23,7 +23,10 @@ | ||
| 23 | // Add a POST variable to the request | 23 | // Add a POST variable to the request |
| 24 | - (void)setPostValue:(id)value forKey:(NSString *)key; | 24 | - (void)setPostValue:(id)value forKey:(NSString *)key; |
| 25 | 25 | ||
| 26 | -// Add the contents of a local file as a POST variable to the request | 26 | +// Add the contents of a local file to the request |
| 27 | - (void)setFile:(NSString *)filePath forKey:(NSString *)key; | 27 | - (void)setFile:(NSString *)filePath forKey:(NSString *)key; |
| 28 | 28 | ||
| 29 | +// Add the contents of an NSData object to the request | ||
| 30 | +- (void)setData:(NSData *)data forKey:(NSString *)key; | ||
| 31 | + | ||
| 29 | @end | 32 | @end |
| @@ -44,7 +44,22 @@ | @@ -44,7 +44,22 @@ | ||
| 44 | if (!fileData) { | 44 | if (!fileData) { |
| 45 | fileData = [[NSMutableDictionary alloc] init]; | 45 | fileData = [[NSMutableDictionary alloc] init]; |
| 46 | } | 46 | } |
| 47 | - [fileData setValue:filePath forKey:key]; | 47 | + NSMutableDictionary *file = [[[NSMutableDictionary alloc] init] autorelease]; |
| 48 | + [file setObject:[NSData dataWithContentsOfFile:filePath options:NSUncachedRead error:NULL] forKey:@"data"]; | ||
| 49 | + [file setObject:[filePath lastPathComponent] forKey:@"filename"]; | ||
| 50 | + [fileData setValue:file forKey:key]; | ||
| 51 | + [self setRequestMethod:@"POST"]; | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +- (void)setData:(NSData *)data forKey:(NSString *)key | ||
| 55 | +{ | ||
| 56 | + if (!fileData) { | ||
| 57 | + fileData = [[NSMutableDictionary alloc] init]; | ||
| 58 | + } | ||
| 59 | + NSMutableDictionary *file = [[[NSMutableDictionary alloc] init] autorelease]; | ||
| 60 | + [file setObject:data forKey:@"data"]; | ||
| 61 | + [file setObject:@"file" forKey:@"filename"]; | ||
| 62 | + [fileData setValue:file forKey:key]; | ||
| 48 | [self setRequestMethod:@"POST"]; | 63 | [self setRequestMethod:@"POST"]; |
| 49 | } | 64 | } |
| 50 | 65 | ||
| @@ -83,10 +98,10 @@ | @@ -83,10 +98,10 @@ | ||
| 83 | e = [fileData keyEnumerator]; | 98 | e = [fileData keyEnumerator]; |
| 84 | i=0; | 99 | i=0; |
| 85 | while (key = [e nextObject]) { | 100 | while (key = [e nextObject]) { |
| 86 | - NSString *filePath = [fileData objectForKey:key]; | 101 | + NSDictionary *fileInfo = [fileData objectForKey:key]; |
| 87 | - [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n",key,[filePath lastPathComponent]] dataUsingEncoding:NSUTF8StringEncoding]]; | 102 | + [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n",key,[fileInfo objectForKey:@"filename"]] dataUsingEncoding:NSUTF8StringEncoding]]; |
| 88 | [body appendData:contentTypeHeader]; | 103 | [body appendData:contentTypeHeader]; |
| 89 | - [body appendData: [NSData dataWithContentsOfFile:filePath options:NSUncachedRead error:NULL]]; | 104 | + [body appendData: [fileInfo objectForKey:@"data"]]; |
| 90 | i++; | 105 | i++; |
| 91 | // Only add the boundary if this is not the last item in the post body | 106 | // Only add the boundary if this is not the last item in the post body |
| 92 | if (i != [fileData count]) { | 107 | if (i != [fileData count]) { |
| @@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
| 15 | 15 | ||
| 16 | - (void)testPostWithFileUpload | 16 | - (void)testPostWithFileUpload |
| 17 | { | 17 | { |
| 18 | + NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/post"]; | ||
| 18 | 19 | ||
| 19 | //Create a 32kb file | 20 | //Create a 32kb file |
| 20 | unsigned int size = 1024*32; | 21 | unsigned int size = 1024*32; |
| @@ -22,14 +23,22 @@ | @@ -22,14 +23,22 @@ | ||
| 22 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bigfile"]; | 23 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bigfile"]; |
| 23 | [data writeToFile:path atomically:NO]; | 24 | [data writeToFile:path atomically:NO]; |
| 24 | 25 | ||
| 25 | - ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/asi-http-request/tests/post"]] autorelease]; | 26 | + ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; |
| 26 | [request setPostValue:@"foo" forKey:@"post_var"]; | 27 | [request setPostValue:@"foo" forKey:@"post_var"]; |
| 27 | [request setFile:path forKey:@"file"]; | 28 | [request setFile:path forKey:@"file"]; |
| 28 | [request start]; | 29 | [request start]; |
| 29 | 30 | ||
| 30 | - | ||
| 31 | BOOL success = ([[request dataString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",@"bigfile",size]]); | 31 | BOOL success = ([[request dataString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",@"bigfile",size]]); |
| 32 | - STAssertTrue(success,@"Failed to upload the correct data"); | 32 | + STAssertTrue(success,@"Failed to upload the correct data (using local file)"); |
| 33 | + | ||
| 34 | + //Try the same with the raw data | ||
| 35 | + request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; | ||
| 36 | + [request setPostValue:@"foo" forKey:@"post_var"]; | ||
| 37 | + [request setData:data forKey:@"file"]; | ||
| 38 | + [request start]; | ||
| 39 | + | ||
| 40 | + success = ([[request dataString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",@"file",size]]); | ||
| 41 | + STAssertTrue(success,@"Failed to upload the correct data (using NSData)"); | ||
| 33 | } | 42 | } |
| 34 | 43 | ||
| 35 | 44 |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | // Copyright 2007-2008 All-Seeing Interactive. All rights reserved. | 5 | // Copyright 2007-2008 All-Seeing Interactive. All rights reserved. |
| 6 | // | 6 | // |
| 7 | // A guide to the main features is available at: | 7 | // A guide to the main features is available at: |
| 8 | -// http://allseeing-i.com/asi-http-request | 8 | +// http://allseeing-i.com/ASIHTTPRequest |
| 9 | // | 9 | // |
| 10 | // Portions are based on the ImageClient example from Apple: | 10 | // Portions are based on the ImageClient example from Apple: |
| 11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html | 11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | // Copyright 2007-2008 All-Seeing Interactive. All rights reserved. | 5 | // Copyright 2007-2008 All-Seeing Interactive. All rights reserved. |
| 6 | // | 6 | // |
| 7 | // A guide to the main features is available at: | 7 | // A guide to the main features is available at: |
| 8 | -// http://allseeing-i.com/asi-http-request | 8 | +// http://allseeing-i.com/ASIHTTPRequest |
| 9 | // | 9 | // |
| 10 | // Portions are based on the ImageClient example from Apple: | 10 | // Portions are based on the ImageClient example from Apple: |
| 11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html | 11 | // See: http://developer.apple.com/samplecode/ImageClient/listing37.html |
| @@ -132,6 +132,7 @@ static NSError *ASIUnableToCreateRequestError; | @@ -132,6 +132,7 @@ static NSError *ASIUnableToCreateRequestError; | ||
| 132 | { | 132 | { |
| 133 | postBody = [body retain]; | 133 | postBody = [body retain]; |
| 134 | postLength = [postBody length]; | 134 | postLength = [postBody length]; |
| 135 | + [self addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%llu",postLength]]; | ||
| 135 | if (postBody && postLength > 0 && ![requestMethod isEqualToString:@"POST"] && ![requestMethod isEqualToString:@"PUT"]) { | 136 | if (postBody && postLength > 0 && ![requestMethod isEqualToString:@"POST"] && ![requestMethod isEqualToString:@"PUT"]) { |
| 136 | [self setRequestMethod:@"POST"]; | 137 | [self setRequestMethod:@"POST"]; |
| 137 | } | 138 | } |
| @@ -329,7 +330,7 @@ static NSError *ASIUnableToCreateRequestError; | @@ -329,7 +330,7 @@ static NSError *ASIUnableToCreateRequestError; | ||
| 329 | [pool release]; | 330 | [pool release]; |
| 330 | pool = [[NSAutoreleasePool alloc] init]; | 331 | pool = [[NSAutoreleasePool alloc] init]; |
| 331 | 332 | ||
| 332 | - NSDate *now = [NSDate new]; | 333 | + NSDate *now = [NSDate date]; |
| 333 | 334 | ||
| 334 | // See if we need to timeout | 335 | // See if we need to timeout |
| 335 | if (lastActivityTime && timeOutSeconds > 0) { | 336 | if (lastActivityTime && timeOutSeconds > 0) { |
| @@ -350,7 +351,6 @@ static NSError *ASIUnableToCreateRequestError; | @@ -350,7 +351,6 @@ static NSError *ASIUnableToCreateRequestError; | ||
| 350 | 351 | ||
| 351 | // This thread should wait for 1/4 second for the stream to do something. We'll stop early if it does. | 352 | // This thread should wait for 1/4 second for the stream to do something. We'll stop early if it does. |
| 352 | CFRunLoopRunInMode(ASIHTTPRequestRunMode,0.25,YES); | 353 | CFRunLoopRunInMode(ASIHTTPRequestRunMode,0.25,YES); |
| 353 | - [now release]; | ||
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | [pool release]; | 356 | [pool release]; |
| @@ -16,7 +16,8 @@ | @@ -16,7 +16,8 @@ | ||
| 16 | - (void)testBasicDownload; | 16 | - (void)testBasicDownload; |
| 17 | - (void)testTimeOut; | 17 | - (void)testTimeOut; |
| 18 | - (void)testRequestMethod; | 18 | - (void)testRequestMethod; |
| 19 | -- (void)testContentLength; | 19 | +- (void)testUploadContentLength; |
| 20 | +- (void)testDownloadContentLength; | ||
| 20 | - (void)testFileDownload; | 21 | - (void)testFileDownload; |
| 21 | - (void)testDownloadProgress; | 22 | - (void)testDownloadProgress; |
| 22 | - (void)testUploadProgress; | 23 | - (void)testUploadProgress; |
| @@ -70,7 +70,7 @@ | @@ -70,7 +70,7 @@ | ||
| 70 | 70 | ||
| 71 | - (void)testRequestMethod | 71 | - (void)testRequestMethod |
| 72 | { | 72 | { |
| 73 | - NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASI-HTTP-Request/tests/request-method"] autorelease]; | 73 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/request-method"] autorelease]; |
| 74 | NSArray *methods = [[[NSArray alloc] initWithObjects:@"GET",@"POST",@"PUT",@"DELETE"] autorelease]; | 74 | NSArray *methods = [[[NSArray alloc] initWithObjects:@"GET",@"POST",@"PUT",@"DELETE"] autorelease]; |
| 75 | for (NSString *method in methods) { | 75 | for (NSString *method in methods) { |
| 76 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 76 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| @@ -81,7 +81,19 @@ | @@ -81,7 +81,19 @@ | ||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | -- (void)testContentLength | 84 | +- (void)testUploadContentLength |
| 85 | +{ | ||
| 86 | + //This url will return the contents of the Content-Length request header | ||
| 87 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/content-length"] autorelease]; | ||
| 88 | + ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
| 89 | + [request setPostBody:[NSMutableData dataWithLength:1024*32]]; | ||
| 90 | + [request start]; | ||
| 91 | + | ||
| 92 | + BOOL success = ([[request dataString] isEqualToString:[NSString stringWithFormat:@"%hu",(1024*32)]]); | ||
| 93 | + STAssertTrue(success,@"Sent wrong content length"); | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +- (void)testDownloadContentLength | ||
| 85 | { | 97 | { |
| 86 | NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/i/logo.png"] autorelease]; | 98 | NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/i/logo.png"] autorelease]; |
| 87 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 99 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| @@ -95,7 +107,7 @@ | @@ -95,7 +107,7 @@ | ||
| 95 | { | 107 | { |
| 96 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"testfile"]; | 108 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"testfile"]; |
| 97 | 109 | ||
| 98 | - NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/first"] autorelease]; | 110 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/first"] autorelease]; |
| 99 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 111 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 100 | [request1 setDownloadDestinationPath:path]; | 112 | [request1 setDownloadDestinationPath:path]; |
| 101 | [request1 start]; | 113 | [request1 start]; |
| @@ -121,7 +133,7 @@ | @@ -121,7 +133,7 @@ | ||
| 121 | - (void)testUploadProgress | 133 | - (void)testUploadProgress |
| 122 | { | 134 | { |
| 123 | progress = 0; | 135 | progress = 0; |
| 124 | - ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://asi/ignore"]] autorelease]; | 136 | + ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ignore"]] autorelease]; |
| 125 | [request setPostBody:[NSMutableData dataWithLength:1024*32]]; | 137 | [request setPostBody:[NSMutableData dataWithLength:1024*32]]; |
| 126 | [request setUploadProgressDelegate:self]; | 138 | [request setUploadProgressDelegate:self]; |
| 127 | [request start]; | 139 | [request start]; |
| @@ -143,7 +155,7 @@ | @@ -143,7 +155,7 @@ | ||
| 143 | BOOL success; | 155 | BOOL success; |
| 144 | 156 | ||
| 145 | // Set setting a cookie | 157 | // Set setting a cookie |
| 146 | - NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/set_cookie"] autorelease]; | 158 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/set_cookie"] autorelease]; |
| 147 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 159 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 148 | [request setUseCookiePersistance:YES]; | 160 | [request setUseCookiePersistance:YES]; |
| 149 | [request start]; | 161 | [request start]; |
| @@ -166,7 +178,7 @@ | @@ -166,7 +178,7 @@ | ||
| 166 | STAssertTrue(success,@"Failed to store the correct value for a cookie"); | 178 | STAssertTrue(success,@"Failed to store the correct value for a cookie"); |
| 167 | success = [[cookie domain] isEqualToString:@"allseeing-i.com"]; | 179 | success = [[cookie domain] isEqualToString:@"allseeing-i.com"]; |
| 168 | STAssertTrue(success,@"Failed to store the correct domain for a cookie"); | 180 | STAssertTrue(success,@"Failed to store the correct domain for a cookie"); |
| 169 | - success = [[cookie path] isEqualToString:@"/asi-http-request/tests"]; | 181 | + success = [[cookie path] isEqualToString:@"/ASIHTTPRequest/tests"]; |
| 170 | STAssertTrue(success,@"Failed to store the correct path for a cookie"); | 182 | STAssertTrue(success,@"Failed to store the correct path for a cookie"); |
| 171 | break; | 183 | break; |
| 172 | } | 184 | } |
| @@ -178,7 +190,7 @@ | @@ -178,7 +190,7 @@ | ||
| 178 | } | 190 | } |
| 179 | 191 | ||
| 180 | // Test a cookie is presented when manually added to the request | 192 | // Test a cookie is presented when manually added to the request |
| 181 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease]; | 193 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 182 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 194 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 183 | [request setUseCookiePersistance:NO]; | 195 | [request setUseCookiePersistance:NO]; |
| 184 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; | 196 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; |
| @@ -188,7 +200,7 @@ | @@ -188,7 +200,7 @@ | ||
| 188 | STAssertTrue(success,@"Cookie not presented to the server with cookie persistance OFF"); | 200 | STAssertTrue(success,@"Cookie not presented to the server with cookie persistance OFF"); |
| 189 | 201 | ||
| 190 | // Test a cookie is presented from the persistent store | 202 | // Test a cookie is presented from the persistent store |
| 191 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease]; | 203 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 192 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 204 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 193 | [request setUseCookiePersistance:YES]; | 205 | [request setUseCookiePersistance:YES]; |
| 194 | [request start]; | 206 | [request start]; |
| @@ -197,7 +209,7 @@ | @@ -197,7 +209,7 @@ | ||
| 197 | STAssertTrue(success,@"Cookie not presented to the server with cookie persistance ON"); | 209 | STAssertTrue(success,@"Cookie not presented to the server with cookie persistance ON"); |
| 198 | 210 | ||
| 199 | // Test removing a cookie | 211 | // Test removing a cookie |
| 200 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/remove_cookie"] autorelease]; | 212 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/remove_cookie"] autorelease]; |
| 201 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 213 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 202 | [request start]; | 214 | [request start]; |
| 203 | html = [request dataString]; | 215 | html = [request dataString]; |
| @@ -205,7 +217,7 @@ | @@ -205,7 +217,7 @@ | ||
| 205 | STAssertTrue(success,@"Failed to remove a cookie"); | 217 | STAssertTrue(success,@"Failed to remove a cookie"); |
| 206 | 218 | ||
| 207 | // Test making sure cookie was properly removed | 219 | // Test making sure cookie was properly removed |
| 208 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease]; | 220 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 209 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 221 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 210 | [request start]; | 222 | [request start]; |
| 211 | html = [request dataString]; | 223 | html = [request dataString]; |
| @@ -218,10 +230,10 @@ | @@ -218,10 +230,10 @@ | ||
| 218 | [cookieProperties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName]; | 230 | [cookieProperties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName]; |
| 219 | [cookieProperties setValue:@"allseeing-i.com" forKey:NSHTTPCookieDomain]; | 231 | [cookieProperties setValue:@"allseeing-i.com" forKey:NSHTTPCookieDomain]; |
| 220 | [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60*4] forKey:NSHTTPCookieExpires]; | 232 | [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60*4] forKey:NSHTTPCookieExpires]; |
| 221 | - [cookieProperties setValue:@"/asi-http-request/tests" forKey:NSHTTPCookiePath]; | 233 | + [cookieProperties setValue:@"/ASIHTTPRequest/tests" forKey:NSHTTPCookiePath]; |
| 222 | cookie = [[[NSHTTPCookie alloc] initWithProperties:cookieProperties] autorelease]; | 234 | cookie = [[[NSHTTPCookie alloc] initWithProperties:cookieProperties] autorelease]; |
| 223 | 235 | ||
| 224 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease]; | 236 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 225 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 237 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 226 | [request setUseCookiePersistance:NO]; | 238 | [request setUseCookiePersistance:NO]; |
| 227 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; | 239 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; |
| @@ -233,7 +245,7 @@ | @@ -233,7 +245,7 @@ | ||
| 233 | // Test removing all cookies works | 245 | // Test removing all cookies works |
| 234 | [ASIHTTPRequest clearSession]; | 246 | [ASIHTTPRequest clearSession]; |
| 235 | 247 | ||
| 236 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease]; | 248 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 237 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 249 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 238 | [request start]; | 250 | [request start]; |
| 239 | html = [request dataString]; | 251 | html = [request dataString]; |
| @@ -245,7 +257,7 @@ | @@ -245,7 +257,7 @@ | ||
| 245 | - (void)testBasicAuthentication | 257 | - (void)testBasicAuthentication |
| 246 | { | 258 | { |
| 247 | 259 | ||
| 248 | - NSURL *url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request/tests/basic-authentication"] autorelease]; | 260 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/basic-authentication"] autorelease]; |
| 249 | ASIHTTPRequest *request; | 261 | ASIHTTPRequest *request; |
| 250 | BOOL success; | 262 | BOOL success; |
| 251 | NSError *err; | 263 | NSError *err; |
| @@ -310,7 +322,7 @@ | @@ -310,7 +322,7 @@ | ||
| 310 | { | 322 | { |
| 311 | [ASIHTTPRequest clearSession]; | 323 | [ASIHTTPRequest clearSession]; |
| 312 | 324 | ||
| 313 | - NSURL *url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request/tests/digest-authentication"] autorelease]; | 325 | + NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/digest-authentication"] autorelease]; |
| 314 | ASIHTTPRequest *request; | 326 | ASIHTTPRequest *request; |
| 315 | BOOL success; | 327 | BOOL success; |
| 316 | NSError *err; | 328 | NSError *err; |
| @@ -95,15 +95,15 @@ | @@ -95,15 +95,15 @@ | ||
| 95 | [networkQueue setShouldCancelAllRequestsOnFailure:NO]; | 95 | [networkQueue setShouldCancelAllRequestsOnFailure:NO]; |
| 96 | 96 | ||
| 97 | NSURL *url; | 97 | NSURL *url; |
| 98 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/first"] autorelease]; | 98 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/first"] autorelease]; |
| 99 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 99 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 100 | [networkQueue addOperation:request1]; | 100 | [networkQueue addOperation:request1]; |
| 101 | 101 | ||
| 102 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/second"] autorelease]; | 102 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/second"] autorelease]; |
| 103 | ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 103 | ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 104 | [networkQueue addOperation:request2]; | 104 | [networkQueue addOperation:request2]; |
| 105 | 105 | ||
| 106 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/third"] autorelease]; | 106 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/third"] autorelease]; |
| 107 | ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 107 | ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 108 | [networkQueue addOperation:request3]; | 108 | [networkQueue addOperation:request3]; |
| 109 | 109 | ||
| @@ -111,7 +111,7 @@ | @@ -111,7 +111,7 @@ | ||
| 111 | requestThatShouldFail = [[ASIHTTPRequest alloc] initWithURL:url]; | 111 | requestThatShouldFail = [[ASIHTTPRequest alloc] initWithURL:url]; |
| 112 | [networkQueue addOperation:requestThatShouldFail]; | 112 | [networkQueue addOperation:requestThatShouldFail]; |
| 113 | 113 | ||
| 114 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/broken"] autorelease]; | 114 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/broken"] autorelease]; |
| 115 | ASIHTTPRequest *request5 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 115 | ASIHTTPRequest *request5 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 116 | [networkQueue addOperation:request5]; | 116 | [networkQueue addOperation:request5]; |
| 117 | 117 | ||
| @@ -165,15 +165,15 @@ | @@ -165,15 +165,15 @@ | ||
| 165 | [networkQueue setQueueDidFinishSelector:@selector(queueFinished:)]; | 165 | [networkQueue setQueueDidFinishSelector:@selector(queueFinished:)]; |
| 166 | 166 | ||
| 167 | NSURL *url; | 167 | NSURL *url; |
| 168 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/first"] autorelease]; | 168 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/first"] autorelease]; |
| 169 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 169 | ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 170 | [networkQueue addOperation:request1]; | 170 | [networkQueue addOperation:request1]; |
| 171 | 171 | ||
| 172 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/second"] autorelease]; | 172 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/second"] autorelease]; |
| 173 | ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 173 | ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 174 | [networkQueue addOperation:request2]; | 174 | [networkQueue addOperation:request2]; |
| 175 | 175 | ||
| 176 | - url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/third"] autorelease]; | 176 | + url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/third"] autorelease]; |
| 177 | ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 177 | ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| 178 | [networkQueue addOperation:request3]; | 178 | [networkQueue addOperation:request3]; |
| 179 | 179 |
| @@ -14,4 +14,4 @@ It provides: | @@ -14,4 +14,4 @@ It provides: | ||
| 14 | * Based on NSOperation to make queuing requests and background operation easy | 14 | * Based on NSOperation to make queuing requests and background operation easy |
| 15 | * Basic unit tests (more to come!) | 15 | * Basic unit tests (more to come!) |
| 16 | 16 | ||
| 17 | -Documentation is available "here":http://allseeing-i.com/ASI-HTTP-REQUEST. | 17 | +Documentation is available "here":http://allseeing-i.com/ASIHTTPRequest. |
-
Please register or login to post a comment