Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/FSNConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions src/FSNConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ @interface FSNConnection ()

@implementation FSNConnection

static NSTimeInterval __defaultTimeoutInterval = 60;

#pragma mark - NSObject

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -325,6 +327,16 @@ + (id)withUrl:(NSURL *)url
return c;
}

+ (int)defaultTimeoutInterval
{
return __defaultTimeoutInterval;
}

+ (void)setDefaultTimeoutInterval:(NSTimeInterval)interval
{
__defaultTimeoutInterval = interval;
}


// MARK: accessors

Expand Down Expand Up @@ -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) \
Expand Down