James Thrasher

Make persistent connection timeout configurable and default to 60s

@@ -342,6 +342,10 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; @@ -342,6 +342,10 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
342 // Persistent connections only work when the server sends a 'Keep-Alive' header 342 // Persistent connections only work when the server sends a 'Keep-Alive' header
343 // Default is YES 343 // Default is YES
344 BOOL shouldAttemptPersistentConnection; 344 BOOL shouldAttemptPersistentConnection;
  345 +
  346 + // Number of seconds to keep an inactive persistent connection open on the client side
  347 + // Default is 60
  348 + NSTimeInterval persistentConnectionTimeout;
345 349
346 // Set to yes when an appropriate keep-alive header is found 350 // Set to yes when an appropriate keep-alive header is found
347 BOOL connectionCanBeReused; 351 BOOL connectionCanBeReused;
@@ -716,6 +720,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; @@ -716,6 +720,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
716 @property (assign) int numberOfTimesToRetryOnTimeout; 720 @property (assign) int numberOfTimesToRetryOnTimeout;
717 @property (assign, readonly) int retryCount; 721 @property (assign, readonly) int retryCount;
718 @property (assign) BOOL shouldAttemptPersistentConnection; 722 @property (assign) BOOL shouldAttemptPersistentConnection;
  723 +@property (assign) NSTimeInterval persistentConnectionTimeout;
719 @property (assign) BOOL shouldUseRFC2616RedirectBehaviour; 724 @property (assign) BOOL shouldUseRFC2616RedirectBehaviour;
720 @property (assign, readonly) BOOL connectionCanBeReused; 725 @property (assign, readonly) BOOL connectionCanBeReused;
721 @end 726 @end
@@ -223,6 +223,7 @@ static BOOL isiPhoneOS2; @@ -223,6 +223,7 @@ static BOOL isiPhoneOS2;
223 [self setRequestMethod:@"GET"]; 223 [self setRequestMethod:@"GET"];
224 224
225 [self setShouldAttemptPersistentConnection:YES]; 225 [self setShouldAttemptPersistentConnection:YES];
  226 + [self setPersistentConnectionTimeout:60.0];
226 [self setShouldPresentCredentialsBeforeChallenge:YES]; 227 [self setShouldPresentCredentialsBeforeChallenge:YES];
227 [self setShouldRedirect:YES]; 228 [self setShouldRedirect:YES];
228 [self setShowAccurateProgress:YES]; 229 [self setShowAccurateProgress:YES];
@@ -1805,7 +1806,10 @@ static BOOL isiPhoneOS2; @@ -1805,7 +1806,10 @@ static BOOL isiPhoneOS2;
1805 // Otherwise, we'll assume we can keep this connection open 1806 // Otherwise, we'll assume we can keep this connection open
1806 } else { 1807 } else {
1807 [self setConnectionCanBeReused:YES]; 1808 [self setConnectionCanBeReused:YES];
1808 - closeStreamTime = 60; 1809 + closeStreamTime = [self persistentConnectionTimeout];
  1810 +#if DEBUG_PERSISTENT_CONNECTIONS
  1811 + NSLog(@"Set connection to close after %f seconds", closeStreamTime);
  1812 +#endif
1809 } 1813 }
1810 } 1814 }
1811 } 1815 }
@@ -3748,6 +3752,7 @@ static BOOL isiPhoneOS2; @@ -3748,6 +3752,7 @@ static BOOL isiPhoneOS2;
3748 @synthesize numberOfTimesToRetryOnTimeout; 3752 @synthesize numberOfTimesToRetryOnTimeout;
3749 @synthesize retryCount; 3753 @synthesize retryCount;
3750 @synthesize shouldAttemptPersistentConnection; 3754 @synthesize shouldAttemptPersistentConnection;
  3755 +@synthesize persistentConnectionTimeout;
3751 @synthesize connectionCanBeReused; 3756 @synthesize connectionCanBeReused;
3752 @synthesize connectionInfo; 3757 @synthesize connectionInfo;
3753 @synthesize readStream; 3758 @synthesize readStream;