Ben Copsey

Lots more reworking - use a pool of connections

@@ -341,7 +341,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; @@ -341,7 +341,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
341 341
342 NSTimeInterval closeStreamTime; 342 NSTimeInterval closeStreamTime;
343 343
344 - int usedStreamNumber; 344 + NSMutableDictionary *usedConnection;
345 } 345 }
346 346
347 #pragma mark init / dealloc 347 #pragma mark init / dealloc
This diff is collapsed. Click to expand it.
@@ -60,19 +60,19 @@ static NSLock *readLock = nil; @@ -60,19 +60,19 @@ static NSLock *readLock = nil;
60 } 60 }
61 [ASIHTTPRequest incrementBandwidthUsedInLastSecond:toRead]; 61 [ASIHTTPRequest incrementBandwidthUsedInLastSecond:toRead];
62 [readLock unlock]; 62 [readLock unlock];
63 - return [[self stream] read:buffer maxLength:toRead]; 63 + return [stream read:buffer maxLength:toRead];
64 } 64 }
65 65
66 // If we get asked to perform a method we don't have (which is almost all of them), we'll just forward the message to our stream 66 // If we get asked to perform a method we don't have (which is almost all of them), we'll just forward the message to our stream
67 67
68 - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector 68 - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
69 { 69 {
70 - return [[self stream] methodSignatureForSelector:aSelector]; 70 + return [stream methodSignatureForSelector:aSelector];
71 } 71 }
72 72
73 - (void)forwardInvocation:(NSInvocation *)anInvocation 73 - (void)forwardInvocation:(NSInvocation *)anInvocation
74 { 74 {
75 - [anInvocation invokeWithTarget:[self stream]]; 75 + [anInvocation invokeWithTarget:stream];
76 } 76 }
77 77
78 @synthesize stream; 78 @synthesize stream;
@@ -139,6 +139,7 @@ @@ -139,6 +139,7 @@
139 [request setPostValue:testString forKey:@"value"]; 139 [request setPostValue:testString forKey:@"value"];
140 [request setPostFormat:ASIMultipartFormDataPostFormat]; 140 [request setPostFormat:ASIMultipartFormDataPostFormat];
141 [request startSynchronous]; 141 [request startSynchronous];
  142 + NSLog(@"%@",[request responseString]);
142 success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); 143 success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]);
143 GHAssertTrue(success,@"Failed to correctly encode the data"); 144 GHAssertTrue(success,@"Failed to correctly encode the data");
144 145
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 @implementation ASIHTTPRequestSubclass; 19 @implementation ASIHTTPRequestSubclass;
20 20
21 // For testing exceptions are caught 21 // For testing exceptions are caught
22 -- (void)loadSynchronous 22 +- (void)startRequest
23 { 23 {
24 [[NSException exceptionWithName:@"Test Exception" reason:@"Test Reason" userInfo:nil] raise]; 24 [[NSException exceptionWithName:@"Test Exception" reason:@"Test Reason" userInfo:nil] raise];
25 } 25 }
@@ -307,7 +307,10 @@ @@ -307,7 +307,10 @@
307 ASIFormDataRequest *request2; 307 ASIFormDataRequest *request2;
308 BOOL success; 308 BOOL success;
309 int i; 309 int i;
310 - for (i=301; i<308; i++) { 310 + for (i=306; i<308; i++) {
  311 + if (i == 305) { // 304s will not contain a body, as per rfc2616. Will test 304 handling in a future test when we have etag support
  312 + continue;
  313 + }
311 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]]; 314 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]];
312 request = [ASIHTTPRequest requestWithURL:url]; 315 request = [ASIHTTPRequest requestWithURL:url];
313 [request setShouldRedirect:NO]; 316 [request setShouldRedirect:NO];
@@ -990,8 +990,8 @@ IMPORTANT @@ -990,8 +990,8 @@ IMPORTANT
990 990
991 991
992 NSTimeInterval interval =[date timeIntervalSinceNow]; 992 NSTimeInterval interval =[date timeIntervalSinceNow];
993 - BOOL success = (interval > -11); 993 + BOOL success = (interval > -10);
994 - GHAssertTrue(success,@"Uploaded the data too slowly - either this is a bug, or your internet connection is too slow to run this test (must be able to upload 320KB in less than 11 seconds, without throttling)"); 994 + GHAssertTrue(success,@"Uploaded the data too slowly - either this is a bug, or your internet connection is too slow to run this test (must be able to upload 160KB in less than 10 seconds, without throttling)");
995 995
996 //NSLog(@"Throttle"); 996 //NSLog(@"Throttle");
997 997
@@ -1050,6 +1050,7 @@ IMPORTANT @@ -1050,6 +1050,7 @@ IMPORTANT
1050 1050
1051 - (void)postDone:(ASIHTTPRequest *)request 1051 - (void)postDone:(ASIHTTPRequest *)request
1052 { 1052 {
  1053 + NSLog(@"%@",[request responseString]);
1053 BOOL success = [[request responseString] isEqualToString:@"This is the first item\r\nThis is the second item"]; 1054 BOOL success = [[request responseString] isEqualToString:@"This is the first item\r\nThis is the second item"];
1054 GHAssertTrue(success,@"Didn't post correct data"); 1055 GHAssertTrue(success,@"Didn't post correct data");
1055 } 1056 }
This diff was suppressed by a .gitattributes entry.