Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prevent requests stealing each others' connections (closes gh-192)

  • Loading branch information...
commit 18a62f634f2ca4b5356872b25e43482bf7042358 1 parent cde3ef6
@pokeb pokeb authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 Classes/ASIHTTPRequest.m
View
13 Classes/ASIHTTPRequest.m
@@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
-NSString *ASIHTTPRequestVersion = @"v1.8-90 2011-05-28";
+NSString *ASIHTTPRequestVersion = @"v1.8-91 2011-05-28";
static NSString *defaultUserAgent = nil;
@@ -1284,7 +1284,7 @@ - (void)startRequest
if (![[[self connectionInfo] objectForKey:@"host"] isEqualToString:[[self url] host]] || ![[[self connectionInfo] objectForKey:@"scheme"] isEqualToString:[[self url] scheme]] || [(NSNumber *)[[self connectionInfo] objectForKey:@"port"] intValue] != [[[self url] port] intValue]) {
[self setConnectionInfo:nil];
-
+
// Check if we should have expired this connection
} else if ([[[self connectionInfo] objectForKey:@"expires"] timeIntervalSinceNow] < 0) {
#if DEBUG_PERSISTENT_CONNECTIONS
@@ -1292,7 +1292,14 @@ - (void)startRequest
#endif
[persistentConnectionsPool removeObject:[self connectionInfo]];
[self setConnectionInfo:nil];
- }
+
+ } else if ([[self connectionInfo] objectForKey:@"request"] != nil) {
+ //Some other request reused this connection already - we'll have to create a new one
+ #if DEBUG_PERSISTENT_CONNECTIONS
+ NSLog(@"%@ - Not re-using connection #%i for request #%i because it is already used by request #%i",self,[[[self connectionInfo] objectForKey:@"id"] intValue],[[self requestID] intValue],[[[self connectionInfo] objectForKey:@"request"] intValue]);
+ #endif
+ [self setConnectionInfo:nil];
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.