1111#import " TMOAuth.h"
1212#import " TMTumblrAuthenticator.h"
1313
14+ static NSTimeInterval const TMAPIClientDefaultRequestTimeoutInterval = 60 ;
15+
1416@interface TMAPIClient ()
1517
1618@property (nonatomic , strong ) JXHTTPOperationQueue *queue;
@@ -200,7 +202,10 @@ - (void)followers:(NSString *)blogName parameters:(NSDictionary *)parameters cal
200202
201203- (JXHTTPOperation *)postsRequest : (NSString *)blogName type : (NSString *)type parameters : (NSDictionary *)parameters {
202204 NSString *path = blogPath (@" posts" , blogName);
203- if (type) path = [path stringByAppendingFormat: @" /%@ " , type];
205+
206+ if (type) {
207+ path = [path stringByAppendingFormat: @" /%@ " , type];
208+ }
204209
205210 return [self getRequestWithPath: path parameters: parameters];
206211}
@@ -376,6 +381,7 @@ - (JXHTTPOperation *)getRequestWithPath:(NSString *)path parameters:(NSDictionar
376381
377382 JXHTTPOperation *request = [JXHTTPOperation withURLString: URLWithPath (path) queryParameters: mutableParameters];
378383 request.continuesInAppBackground = YES ;
384+ request.requestTimeoutInterval = self.timeoutInterval ;
379385
380386 [self signRequest: request withParameters: nil ];
381387
@@ -390,6 +396,7 @@ - (JXHTTPOperation *)postRequestWithPath:(NSString *)path parameters:(NSDictiona
390396 request.requestMethod = @" POST" ;
391397 request.continuesInAppBackground = YES ;
392398 request.requestBody = [JXHTTPFormEncodedBody withDictionary: mutableParameters];
399+ request.requestTimeoutInterval = self.timeoutInterval ;
393400
394401 [self signRequest: request withParameters: mutableParameters];
395402
@@ -408,6 +415,7 @@ - (JXHTTPOperation *)multipartPostRequest:(NSString *)blogName type:(NSString *)
408415 request.continuesInAppBackground = YES ;
409416 request.requestBody = [self multipartBodyForParameters: mutableParameters filePathArray: filePathArray
410417 contentTypeArray: contentTypeArray fileNameArray: fileNameArray];
418+ request.requestTimeoutInterval = self.timeoutInterval ;
411419
412420 [self signRequest: request withParameters: mutableParameters];
413421
@@ -482,8 +490,9 @@ - (void)sendRequest:(JXHTTPOperation *)request queue:(NSOperationQueue *)queue c
482490}
483491
484492NSString *fullBlogName (NSString *blogName) {
485- if ([blogName rangeOfString: @" ." ].location == NSNotFound )
493+ if ([blogName rangeOfString: @" ." ].location == NSNotFound ) {
486494 return blogName = [blogName stringByAppendingString: @" .tumblr.com" ];
495+ }
487496
488497 return blogName;
489498}
@@ -498,6 +507,7 @@ - (id)init {
498507 if (self = [super init ]) {
499508 self.queue = [[JXHTTPOperationQueue alloc ] init ];
500509 self.defaultCallbackQueue = [NSOperationQueue mainQueue ];
510+ self.timeoutInterval = TMAPIClientDefaultRequestTimeoutInterval;
501511 }
502512
503513 return self;
0 commit comments