diff --git a/src/FSNConnection.h b/src/FSNConnection.h index 382b723..550f1f3 100644 --- a/src/FSNConnection.h +++ b/src/FSNConnection.h @@ -105,7 +105,7 @@ NSString* stringForRequestMethod(FSNRequestMethod method); @property (nonatomic, readonly) NSTimeInterval responseInterval; @property (nonatomic, readonly) NSTimeInterval finishOrFailInterval; @property (nonatomic, readonly) NSTimeInterval parseInterval; - +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + (id)withUrl:(NSURL *)url method:(FSNRequestMethod)method @@ -118,6 +118,8 @@ progressBlock:(FSNProgressBlock)progressBlock; + (NSSet *)connections; + (void)cancelAllConnections; ++ (int)defaultTimeoutInterval; ++ (void)setDefaultTimeoutInterval:(NSTimeInterval)interval; // call this method to allow the request to complete but ignore the response. diff --git a/src/FSNConnection.m b/src/FSNConnection.m index 75600b5..1034665 100644 --- a/src/FSNConnection.m +++ b/src/FSNConnection.m @@ -80,6 +80,7 @@ @interface FSNConnection () @implementation FSNConnection +static NSTimeInterval __defaultTimeoutInterval = 60; #pragma mark - NSObject @@ -122,6 +123,7 @@ - (id)init { // - calling clearBlocks may cause an object in the block closure to be released // - that may in turn 'own' the connection, and call clearBlocks to properly break retain cycles in all cases. self.blocksLock = [NSRecursiveLock new]; + self.timeoutInterval = __defaultTimeoutInterval ; return self; } @@ -325,6 +327,16 @@ + (id)withUrl:(NSURL *)url return c; } ++ (int)defaultTimeoutInterval +{ + return __defaultTimeoutInterval; +} + ++ (void)setDefaultTimeoutInterval:(NSTimeInterval)interval +{ + __defaultTimeoutInterval = interval; +} + // MARK: accessors @@ -763,6 +775,7 @@ - (NSURLRequest*)makeNSURLRequest { #endif [r setHTTPMethod:stringForRequestMethod(self.method)]; + [r setTimeoutInterval:self.timeoutInterval]; #if FSN_LOG_HEADERS #define SET_HEADER(k, v) \