Showing
7 changed files
with
73 additions
and
62 deletions
@@ -53,10 +53,7 @@ | @@ -53,10 +53,7 @@ | ||
53 | if (!fileData) { | 53 | if (!fileData) { |
54 | fileData = [[NSMutableDictionary alloc] init]; | 54 | fileData = [[NSMutableDictionary alloc] init]; |
55 | } | 55 | } |
56 | - NSMutableDictionary *file = [[[NSMutableDictionary alloc] init] autorelease]; | 56 | + [fileData setObject:data forKey:key]; |
57 | - [file setObject:data forKey:@"data"]; | ||
58 | - [file setObject:@"file" forKey:@"filename"]; | ||
59 | - [fileData setValue:file forKey:key]; | ||
60 | [self setRequestMethod:@"POST"]; | 57 | [self setRequestMethod:@"POST"]; |
61 | } | 58 | } |
62 | 59 | ||
@@ -97,10 +94,18 @@ | @@ -97,10 +94,18 @@ | ||
97 | e = [fileData keyEnumerator]; | 94 | e = [fileData keyEnumerator]; |
98 | i=0; | 95 | i=0; |
99 | while (key = [e nextObject]) { | 96 | while (key = [e nextObject]) { |
100 | - NSString *filePath = [fileData objectForKey:key]; | 97 | + NSString *fileName = @"file"; |
101 | - [self appendPostData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n",key,[filePath lastPathComponent]] dataUsingEncoding:NSUTF8StringEncoding]]; | 98 | + id file = [fileData objectForKey:key]; |
99 | + if ([file isKindOfClass:[NSString class]]) { | ||
100 | + fileName = (NSString *)file; | ||
101 | + } | ||
102 | + [self appendPostData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n",key,fileName] dataUsingEncoding:NSUTF8StringEncoding]]; | ||
102 | [self appendPostData:contentTypeHeader]; | 103 | [self appendPostData:contentTypeHeader]; |
103 | - [self appendPostDataFromFile:filePath]; | 104 | + if ([file isKindOfClass:[NSString class]]) { |
105 | + [self appendPostDataFromFile:fileName]; | ||
106 | + } else { | ||
107 | + [self appendPostData:file]; | ||
108 | + } | ||
104 | i++; | 109 | i++; |
105 | // Only add the boundary if this is not the last item in the post body | 110 | // Only add the boundary if this is not the last item in the post body |
106 | if (i != [fileData count]) { | 111 | if (i != [fileData count]) { |
@@ -391,4 +391,5 @@ typedef enum _ASINetworkErrorType { | @@ -391,4 +391,5 @@ typedef enum _ASINetworkErrorType { | ||
391 | @property (retain) NSInputStream *postBodyReadStream; | 391 | @property (retain) NSInputStream *postBodyReadStream; |
392 | @property (assign) BOOL shouldStreamPostDataFromDisk; | 392 | @property (assign) BOOL shouldStreamPostDataFromDisk; |
393 | @property (assign) BOOL didCreateTemporaryPostDataFile; | 393 | @property (assign) BOOL didCreateTemporaryPostDataFile; |
394 | + | ||
394 | @end | 395 | @end |
@@ -213,18 +213,19 @@ static NSError *ASIUnableToCreateRequestError; | @@ -213,18 +213,19 @@ static NSError *ASIUnableToCreateRequestError; | ||
213 | [self setupPostBody]; | 213 | [self setupPostBody]; |
214 | NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:file] autorelease]; | 214 | NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:file] autorelease]; |
215 | [stream open]; | 215 | [stream open]; |
216 | - | ||
217 | NSMutableData *d; | 216 | NSMutableData *d; |
218 | while ([stream hasBytesAvailable]) { | 217 | while ([stream hasBytesAvailable]) { |
219 | - d = [[NSMutableData alloc] initWithLength:256*1024]; | 218 | + d = [NSMutableData dataWithLength:256*1024]; |
220 | int bytesRead = [stream read:[d mutableBytes] maxLength:256*1024]; | 219 | int bytesRead = [stream read:[d mutableBytes] maxLength:256*1024]; |
220 | + if (bytesRead == 0) { | ||
221 | + break; | ||
222 | + } | ||
223 | + [d setLength:bytesRead]; | ||
221 | if ([self shouldStreamPostDataFromDisk]) { | 224 | if ([self shouldStreamPostDataFromDisk]) { |
222 | [[self postBodyWriteStream] write:[d mutableBytes] maxLength:bytesRead]; | 225 | [[self postBodyWriteStream] write:[d mutableBytes] maxLength:bytesRead]; |
223 | } else { | 226 | } else { |
224 | - NSLog(@"foo"); | ||
225 | [[self postBody] appendData:[NSData dataWithBytes:[d mutableBytes] length:bytesRead]]; | 227 | [[self postBody] appendData:[NSData dataWithBytes:[d mutableBytes] length:bytesRead]]; |
226 | } | 228 | } |
227 | - [d release]; | ||
228 | } | 229 | } |
229 | [stream close]; | 230 | [stream close]; |
230 | } | 231 | } |
@@ -273,6 +274,7 @@ static NSError *ASIUnableToCreateRequestError; | @@ -273,6 +274,7 @@ static NSError *ASIUnableToCreateRequestError; | ||
273 | } | 274 | } |
274 | } | 275 | } |
275 | 276 | ||
277 | + | ||
276 | #pragma mark request logic | 278 | #pragma mark request logic |
277 | 279 | ||
278 | // Create the request | 280 | // Create the request |
@@ -289,6 +291,10 @@ static NSError *ASIUnableToCreateRequestError; | @@ -289,6 +291,10 @@ static NSError *ASIUnableToCreateRequestError; | ||
289 | return; | 291 | return; |
290 | } | 292 | } |
291 | 293 | ||
294 | + if (!haveBuiltPostBody) { | ||
295 | + [self buildPostBody]; | ||
296 | + } | ||
297 | + | ||
292 | // Create a new HTTP request. | 298 | // Create a new HTTP request. |
293 | request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)requestMethod, (CFURLRef)url, kCFHTTPVersion1_1); | 299 | request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)requestMethod, (CFURLRef)url, kCFHTTPVersion1_1); |
294 | if (!request) { | 300 | if (!request) { |
@@ -335,11 +341,6 @@ static NSError *ASIUnableToCreateRequestError; | @@ -335,11 +341,6 @@ static NSError *ASIUnableToCreateRequestError; | ||
335 | } | 341 | } |
336 | 342 | ||
337 | 343 | ||
338 | - if (!haveBuiltPostBody) { | ||
339 | - [self buildPostBody]; | ||
340 | - } | ||
341 | - | ||
342 | - | ||
343 | // Accept a compressed response | 344 | // Accept a compressed response |
344 | if ([self allowCompressedResponse]) { | 345 | if ([self allowCompressedResponse]) { |
345 | [self addRequestHeader:@"Accept-Encoding" value:@"gzip"]; | 346 | [self addRequestHeader:@"Accept-Encoding" value:@"gzip"]; |
@@ -545,21 +546,26 @@ static NSError *ASIUnableToCreateRequestError; | @@ -545,21 +546,26 @@ static NSError *ASIUnableToCreateRequestError; | ||
545 | 546 | ||
546 | - (void)removeTemporaryDownloadFile | 547 | - (void)removeTemporaryDownloadFile |
547 | { | 548 | { |
548 | - //Remove the temporary file | 549 | + if (temporaryFileDownloadPath) { |
549 | - NSError *removeError = nil; | 550 | + NSError *removeError = nil; |
550 | - [[NSFileManager defaultManager] removeItemAtPath:temporaryFileDownloadPath error:&removeError]; | 551 | + [[NSFileManager defaultManager] removeItemAtPath:temporaryFileDownloadPath error:&removeError]; |
551 | - if (removeError) { | 552 | + if (removeError) { |
552 | - [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at %@ with error: %@",temporaryFileDownloadPath,removeError],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]]]; | 553 | + [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at %@ with error: %@",temporaryFileDownloadPath,removeError],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]]]; |
553 | - } | 554 | + } |
555 | + [self setTemporaryFileDownloadPath:nil]; | ||
556 | + } | ||
554 | } | 557 | } |
555 | 558 | ||
556 | - (void)removePostDataFile | 559 | - (void)removePostDataFile |
557 | { | 560 | { |
558 | - NSError *removeError = nil; | 561 | + if (postBodyFilePath) { |
559 | - [[NSFileManager defaultManager] removeItemAtPath:postBodyFilePath error:&removeError]; | 562 | + NSError *removeError = nil; |
560 | - if (removeError) { | 563 | + [[NSFileManager defaultManager] removeItemAtPath:postBodyFilePath error:&removeError]; |
561 | - [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at %@ with error: %@",postBodyFilePath,removeError],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]]]; | 564 | + if (removeError) { |
562 | - } | 565 | + [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to delete file at %@ with error: %@",postBodyFilePath,removeError],NSLocalizedDescriptionKey,removeError,NSUnderlyingErrorKey,nil]]]; |
566 | + } | ||
567 | + [self setPostBodyFilePath:nil]; | ||
568 | + } | ||
563 | } | 569 | } |
564 | 570 | ||
565 | 571 | ||
@@ -819,7 +825,7 @@ static NSError *ASIUnableToCreateRequestError; | @@ -819,7 +825,7 @@ static NSError *ASIUnableToCreateRequestError; | ||
819 | [invocation setSelector:selector]; | 825 | [invocation setSelector:selector]; |
820 | [invocation setArgument:&progress atIndex:2]; | 826 | [invocation setArgument:&progress atIndex:2]; |
821 | 827 | ||
822 | - // If we're running in the main thread, update the progress straight away. Otherwise, it's not that urgent | 828 | + |
823 | [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:indicator waitUntilDone:[NSThread isMainThread]]; | 829 | [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:indicator waitUntilDone:[NSThread isMainThread]]; |
824 | 830 | ||
825 | } | 831 | } |
@@ -838,8 +844,6 @@ static NSError *ASIUnableToCreateRequestError; | @@ -838,8 +844,6 @@ static NSError *ASIUnableToCreateRequestError; | ||
838 | } | 844 | } |
839 | } | 845 | } |
840 | 846 | ||
841 | - | ||
842 | - | ||
843 | // Subclasses can override this method to perform error handling in the same thread | 847 | // Subclasses can override this method to perform error handling in the same thread |
844 | // If not overidden, it will call the didFailSelector on the delegate (by default requestFailed:)` | 848 | // If not overidden, it will call the didFailSelector on the delegate (by default requestFailed:)` |
845 | - (void)failWithError:(NSError *)theError | 849 | - (void)failWithError:(NSError *)theError |
@@ -1533,7 +1537,6 @@ static NSError *ASIUnableToCreateRequestError; | @@ -1533,7 +1537,6 @@ static NSError *ASIUnableToCreateRequestError; | ||
1533 | (void)inflateEnd(&strm); | 1537 | (void)inflateEnd(&strm); |
1534 | return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; | 1538 | return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; |
1535 | } | 1539 | } |
1536 | - | ||
1537 | 1540 | ||
1538 | @synthesize username; | 1541 | @synthesize username; |
1539 | @synthesize password; | 1542 | @synthesize password; |
@@ -42,6 +42,10 @@ | @@ -42,6 +42,10 @@ | ||
42 | 42 | ||
43 | - (void)dealloc | 43 | - (void)dealloc |
44 | { | 44 | { |
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 | ||
46 | + for (ASIHTTPRequest *request in [self operations]) { | ||
47 | + [request setDelegate:nil]; | ||
48 | + } | ||
45 | [super dealloc]; | 49 | [super dealloc]; |
46 | } | 50 | } |
47 | 51 |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | 13 | ||
14 | - (void)testPostWithFileUpload | 14 | - (void)testPostWithFileUpload |
15 | { | 15 | { |
16 | - NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/post"]; | 16 | + NSURL *url = [NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/post"]; |
17 | 17 | ||
18 | //Create a 32kb file | 18 | //Create a 32kb file |
19 | unsigned int size = 1024*32; | 19 | unsigned int size = 1024*32; |
@@ -33,8 +33,11 @@ | @@ -33,8 +33,11 @@ | ||
33 | [request setPostValue:d forKey:@"post_var2"]; | 33 | [request setPostValue:d forKey:@"post_var2"]; |
34 | [request setPostValue:v forKey:@"post_var3"]; | 34 | [request setPostValue:v forKey:@"post_var3"]; |
35 | [request setFile:path forKey:@"file"]; | 35 | [request setFile:path forKey:@"file"]; |
36 | + [request setPostBodyFilePath:@"/Users/ben/Desktop/111.txt"]; | ||
36 | [request start]; | 37 | [request start]; |
37 | 38 | ||
39 | + NSLog([request responseString]); | ||
40 | + NSLog([NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"bigfile",size]); | ||
38 | BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"bigfile",size]]); | 41 | BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"bigfile",size]]); |
39 | GHAssertTrue(success,@"Failed to upload the correct data (using local file)"); | 42 | GHAssertTrue(success,@"Failed to upload the correct data (using local file)"); |
40 | 43 | ||
@@ -45,7 +48,9 @@ | @@ -45,7 +48,9 @@ | ||
45 | [request setPostValue:v forKey:@"post_var3"]; | 48 | [request setPostValue:v forKey:@"post_var3"]; |
46 | [request setData:data forKey:@"file"]; | 49 | [request setData:data forKey:@"file"]; |
47 | [request start]; | 50 | [request start]; |
48 | - | 51 | + |
52 | + NSLog([request responseString]); | ||
53 | + NSLog([NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"bigfile",size]); | ||
49 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"file",size]]); | 54 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu",@"foo",d,v,@"file",size]]); |
50 | GHAssertTrue(success,@"Failed to upload the correct data (using NSData)"); | 55 | GHAssertTrue(success,@"Failed to upload the correct data (using NSData)"); |
51 | } | 56 | } |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | 13 | ||
14 | 14 | ||
15 | @implementation ASIHTTPRequestTests | 15 | @implementation ASIHTTPRequestTests |
16 | -/* | 16 | + |
17 | 17 | ||
18 | - (void)testBasicDownload | 18 | - (void)testBasicDownload |
19 | { | 19 | { |
@@ -165,7 +165,7 @@ | @@ -165,7 +165,7 @@ | ||
165 | [request start]; | 165 | [request start]; |
166 | 166 | ||
167 | NSString *tempPath = [request temporaryFileDownloadPath]; | 167 | NSString *tempPath = [request temporaryFileDownloadPath]; |
168 | - GHAssertNotNil(tempPath,@"Failed to download file to temporary location"); | 168 | + GHAssertNil(tempPath,@"Failed to clean up temporary download file"); |
169 | 169 | ||
170 | //BOOL success = (![[NSFileManager defaultManager] fileExistsAtPath:tempPath]); | 170 | //BOOL success = (![[NSFileManager defaultManager] fileExistsAtPath:tempPath]); |
171 | //GHAssertTrue(success,@"Failed to remove file from temporary location"); | 171 | //GHAssertTrue(success,@"Failed to remove file from temporary location"); |
@@ -188,7 +188,7 @@ | @@ -188,7 +188,7 @@ | ||
188 | GHAssertTrue(success,@"Failed to properly increment download progress %f != 1.0",progress); | 188 | GHAssertTrue(success,@"Failed to properly increment download progress %f != 1.0",progress); |
189 | } | 189 | } |
190 | 190 | ||
191 | -*/ | 191 | + |
192 | 192 | ||
193 | 193 | ||
194 | - (void)setProgress:(float)newProgress; | 194 | - (void)setProgress:(float)newProgress; |
@@ -201,7 +201,7 @@ | @@ -201,7 +201,7 @@ | ||
201 | { | 201 | { |
202 | progress = 0; | 202 | progress = 0; |
203 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ignore"]] autorelease]; | 203 | ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ignore"]] autorelease]; |
204 | - [request setPostBody:[NSMutableData dataWithLength:1024*32]]; | 204 | + [request setPostBody:(NSMutableData *)[@"This is the request body" dataUsingEncoding:NSUTF8StringEncoding]]; |
205 | [request setUploadProgressDelegate:self]; | 205 | [request setUploadProgressDelegate:self]; |
206 | [request start]; | 206 | [request start]; |
207 | 207 | ||
@@ -211,9 +211,11 @@ | @@ -211,9 +211,11 @@ | ||
211 | 211 | ||
212 | - (void)testPostBodyStreamedFromDisk | 212 | - (void)testPostBodyStreamedFromDisk |
213 | { | 213 | { |
214 | - NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ignore"]; | 214 | + NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/print_request_body"]; |
215 | + NSString *requestBody = @"This is the request body"; | ||
215 | NSString *requestContentPath = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"testfile.txt"]; | 216 | NSString *requestContentPath = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"testfile.txt"]; |
216 | - [[NSMutableData dataWithLength:1024*32] writeToFile:requestContentPath atomically:NO]; | 217 | + [[requestBody dataUsingEncoding:NSUTF8StringEncoding] writeToFile:requestContentPath atomically:NO]; |
218 | + | ||
217 | 219 | ||
218 | // Test using a user-specified file as the request body (useful for PUT) | 220 | // Test using a user-specified file as the request body (useful for PUT) |
219 | progress = 0; | 221 | progress = 0; |
@@ -222,36 +224,32 @@ | @@ -222,36 +224,32 @@ | ||
222 | [request setShouldStreamPostDataFromDisk:YES]; | 224 | [request setShouldStreamPostDataFromDisk:YES]; |
223 | [request setUploadProgressDelegate:self]; | 225 | [request setUploadProgressDelegate:self]; |
224 | [request setPostBodyFilePath:requestContentPath]; | 226 | [request setPostBodyFilePath:requestContentPath]; |
225 | - //[request start]; | 227 | + [request start]; |
226 | - | ||
227 | - | ||
228 | - //Wait for 1 second | ||
229 | - //[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; | ||
230 | 228 | ||
231 | BOOL success = (progress > 0.95); | 229 | BOOL success = (progress > 0.95); |
232 | - //GHAssertTrue(success,@"Failed to properly increment upload progress %f != 1.0",progress); | 230 | + GHAssertTrue(success,@"Failed to properly increment upload progress %f != 1.0",progress); |
231 | + | ||
232 | + success = [[request responseString] isEqualToString:requestBody]; | ||
233 | + GHAssertTrue(success,@"Failed upload the correct request body"); | ||
233 | 234 | ||
234 | 235 | ||
235 | // Test building a request body by appending data | 236 | // Test building a request body by appending data |
236 | progress = 0; | 237 | progress = 0; |
237 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 238 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
238 | [request setShouldStreamPostDataFromDisk:YES]; | 239 | [request setShouldStreamPostDataFromDisk:YES]; |
240 | + [request setRequestMethod:@"PUT"]; | ||
239 | [request setUploadProgressDelegate:self]; | 241 | [request setUploadProgressDelegate:self]; |
240 | - | ||
241 | - NSData *d = [@"Below this will be the file I am posting:\r\n" dataUsingEncoding:NSUTF8StringEncoding]; | ||
242 | - [request appendPostData:[NSData dataWithBytes:[d bytes] length:[d length]]]; | ||
243 | [request appendPostDataFromFile:requestContentPath]; | 242 | [request appendPostDataFromFile:requestContentPath]; |
244 | [request start]; | 243 | [request start]; |
245 | 244 | ||
246 | - | ||
247 | - //Wait for 1 second | ||
248 | - [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; | ||
249 | - | ||
250 | success = (progress > 0.95); | 245 | success = (progress > 0.95); |
251 | GHAssertTrue(success,@"Failed to properly increment upload progress %f != 1.0",progress); | 246 | GHAssertTrue(success,@"Failed to properly increment upload progress %f != 1.0",progress); |
247 | + | ||
248 | + success = [[request responseString] isEqualToString:requestBody]; | ||
249 | + GHAssertTrue(success,@"Failed upload the correct request body"); | ||
252 | } | 250 | } |
253 | 251 | ||
254 | -/* | 252 | + |
255 | 253 | ||
256 | 254 | ||
257 | - (void)testCookies | 255 | - (void)testCookies |
@@ -571,9 +569,8 @@ | @@ -571,9 +569,8 @@ | ||
571 | success = ([newPartialContent isEqualToString:@"This is the content we ought to be getting if we start from byte 95."]); | 569 | success = ([newPartialContent isEqualToString:@"This is the content we ought to be getting if we start from byte 95."]); |
572 | GHAssertTrue(success,@"Failed to append the correct data to the end of the file?"); | 570 | GHAssertTrue(success,@"Failed to append the correct data to the end of the file?"); |
573 | 571 | ||
574 | - success = success = (progress > 0.95); | 572 | + success = (progress > 0.95); |
575 | GHAssertTrue(success,@"Failed to correctly display increment progress for a partial download"); | 573 | GHAssertTrue(success,@"Failed to correctly display increment progress for a partial download"); |
576 | } | 574 | } |
577 | -*/ | ||
578 | 575 | ||
579 | @end | 576 | @end |
@@ -91,9 +91,9 @@ | @@ -91,9 +91,9 @@ | ||
91 | 91 | ||
92 | NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ignore"]; | 92 | NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ignore"]; |
93 | 93 | ||
94 | - int fileSizes[4] = {16,64,128,512}; | 94 | + int fileSizes[3] = {16,64,257}; |
95 | int i; | 95 | int i; |
96 | - for (i=0; i<4; i++) { | 96 | + for (i=0; i<3; i++) { |
97 | NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; | 97 | NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; |
98 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; | 98 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; |
99 | [data writeToFile:path atomically:NO]; | 99 | [data writeToFile:path atomically:NO]; |
@@ -117,7 +117,7 @@ | @@ -117,7 +117,7 @@ | ||
117 | [networkQueue cancelAllOperations]; | 117 | [networkQueue cancelAllOperations]; |
118 | [networkQueue setShowAccurateProgress:YES]; | 118 | [networkQueue setShowAccurateProgress:YES]; |
119 | 119 | ||
120 | - for (i=0; i<4; i++) { | 120 | + for (i=0; i<3; i++) { |
121 | NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; | 121 | NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; |
122 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; | 122 | NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; |
123 | [data writeToFile:path atomically:NO]; | 123 | [data writeToFile:path atomically:NO]; |
@@ -135,12 +135,8 @@ | @@ -135,12 +135,8 @@ | ||
135 | success = (progress > 0.95); | 135 | success = (progress > 0.95); |
136 | GHAssertTrue(success,@"Failed to increment progress properly"); | 136 | GHAssertTrue(success,@"Failed to increment progress properly"); |
137 | 137 | ||
138 | - | ||
139 | [networkQueue release]; | 138 | [networkQueue release]; |
140 | 139 | ||
141 | - | ||
142 | - | ||
143 | - | ||
144 | } | 140 | } |
145 | 141 | ||
146 | 142 |
-
Please register or login to post a comment