Skip to content

Commit a4283b1

Browse files
committed
- OCHTTPRequest: add support for custom timeouts
- OCConnection: increase timeout for infinite PROPFIND to 6 minutes using new custom timeouts, in case a proxy first
1 parent c778919 commit a4283b1

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

ownCloudSDK/Connection/OCConnection.m

+5
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,11 @@ - (NSProgress *)retrieveItemListAtPath:(OCPath)path depth:(NSUInteger)depth opti
18021802
davRequest.downloadRequest = YES;
18031803
davRequest.priority = NSURLSessionTaskPriorityHigh;
18041804
davRequest.forceCertificateDecisionDelegation = YES;
1805+
if (depth == OCPropfindDepthInfinity)
1806+
{
1807+
// Extend timeout to 5 minutes for infinite PROPFIND
1808+
davRequest.customTimeout = @(5 * 60.0);
1809+
}
18051810

18061811
if (options[OCConnectionOptionRequestObserverKey] != nil)
18071812
{

ownCloudSDK/HTTP/Request/OCHTTPRequest.h

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ typedef NSDictionary<OCHTTPRequestResumeInfoKey,id>* OCHTTPRequestResumeInfo;
106106
@property(strong) OCEventTarget *eventTarget; //!< The target the parsed result should be delivered to as an event.
107107
@property(strong) NSDictionary *userInfo; //!< User-info for free use. All contents should be serializable.
108108

109+
@property(strong) NSNumber *customTimeout; //!< Custom timeout in seconds for request.
110+
109111
@property(assign) OCHTTPRequestPriority priority; //!< Priority of the request from 0.0 (lowest priority) to 1.0 (highest priority). Defaults to NSURLSessionTaskPriorityDefault (= 0.5).
110112
@property(strong) OCHTTPRequestGroupID groupID; //!< ID of the Group the request belongs to (if any). Requests in the same group are executed serially, whereas requests that belong to no group are executed as soon as possible.
111113

ownCloudSDK/HTTP/Request/OCHTTPRequest.m

+12-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,14 @@ - (void)prepareForScheduling
281281
- (NSMutableURLRequest *)generateURLRequest
282282
{
283283
NSMutableURLRequest *urlRequest;
284-
285-
if ((urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.effectiveURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]) != nil)
284+
NSTimeInterval timeoutInterval = 60;
285+
286+
if (self.customTimeout != nil)
287+
{
288+
timeoutInterval = self.customTimeout.doubleValue;
289+
}
290+
291+
if ((urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.effectiveURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]) != nil)
286292
{
287293
// Apply method
288294
urlRequest.HTTPMethod = self.method;
@@ -589,6 +595,8 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
589595
self.eventTarget = [decoder decodeObjectOfClass:[OCEventTarget class] forKey:@"eventTarget"];
590596
self.userInfo = [decoder decodeObjectOfClasses:OCEvent.safeClasses forKey:@"userInfo"];
591597

598+
self.customTimeout = [decoder decodeObjectOfClass:NSNumber.class forKey:@"customTimeout"];
599+
592600
self.priority = [decoder decodeFloatForKey:@"priority"];
593601
self.groupID = [decoder decodeObjectOfClass:[NSString class] forKey:@"groupID"];
594602

@@ -644,6 +652,8 @@ - (void)encodeWithCoder:(NSCoder *)coder
644652
[coder encodeObject:_eventTarget forKey:@"eventTarget"];
645653
[coder encodeObject:_userInfo forKey:@"userInfo"];
646654

655+
[coder encodeObject:_customTimeout forKey:@"customTimeout"];
656+
647657
[coder encodeFloat:_priority forKey:@"priority"];
648658
[coder encodeObject:_groupID forKey:@"groupID"];
649659

0 commit comments

Comments
 (0)