chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gavincornw...@apache.org
Subject svn commit: r1644862 - in /chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils: CMISDefaultNetworkProvider.m CMISHttpDownloadRequest.h CMISHttpDownloadRequest.m CMISHttpRequest.h CMISHttpRequest.m CMISHttpUploadRequest.h CMISHttpUploadRequest.m
Date Fri, 12 Dec 2014 11:47:38 GMT
Author: gavincornwell
Date: Fri Dec 12 11:47:38 2014
New Revision: 1644862

URL: http://svn.apache.org/r1644862
Log:
Final part of CMIS-874 (Switch from NSURLConnection to NSURLSession).

Several new session parameters have been added to control the use of background sessions.
Setting the "kCMISSessionParameterUseBackgroundNetworkSession" key to YES will create a background
network session. 

An identifier for the session and the shared container is required when using background mode,
these can be set via the "kCMISSessionParameterBackgroundNetworkSessionId" and "kCMISSessionParameterBackgroundNetworkSessionSharedContainerId"
keys, respectively. If they are not supplied default values are used, "ObjectiveCMIS" for
the background identifier and "ObjectiveCMISContainer" for the shared container.

Two additional session parameter keys have been added to control request timeout (kCMISSessionParameterRequestTimeout)
and whether network reachability checks are performed (kCMISSessionParameterCheckNetworkReachability).

Modified:
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISDefaultNetworkProvider.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISDefaultNetworkProvider.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISDefaultNetworkProvider.m?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISDefaultNetworkProvider.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISDefaultNetworkProvider.m Fri Dec
12 11:47:38 2014
@@ -46,7 +46,7 @@ completionBlock:(void (^)(CMISHttpRespon
                                                       httpMethod:httpRequestMethod
                                                      requestBody:body
                                                          headers:additionalHeaders
-                                          authenticationProvider:session.authenticationProvider
+                                                         session:session
                                                  completionBlock:completionBlock];
         if (request)
         {
@@ -74,13 +74,13 @@ completionBlock:(void (^)(CMISHttpRespon
                                                                                   session:session];
         
         CMISHttpUploadRequest* request = [CMISHttpUploadRequest startRequest:urlRequest
-                                                           httpMethod:httpRequestMethod
-                                                          inputStream:inputStream
-                                                              headers:additionalHeaders
-                                                        bytesExpected:0
-                                               authenticationProvider:session.authenticationProvider
-                                                      completionBlock:completionBlock
-                                                        progressBlock:nil];
+                                                                  httpMethod:httpRequestMethod
+                                                                 inputStream:inputStream
+                                                                     headers:additionalHeaders
+                                                               bytesExpected:0
+                                                                     session:session
+                                                             completionBlock:completionBlock
+                                                               progressBlock:nil];
         if (request)
         {
             cmisRequest.httpRequest = request;
@@ -109,13 +109,13 @@ completionBlock:(void (^)(CMISHttpRespon
                                                                                   session:session];
         
         CMISHttpUploadRequest* request = [CMISHttpUploadRequest startRequest:urlRequest
-                                                           httpMethod:httpRequestMethod
-                                                          inputStream:inputStream
-                                                              headers:additionalHeaders
-                                                        bytesExpected:bytesExpected
-                                               authenticationProvider:session.authenticationProvider
-                                                      completionBlock:completionBlock
-                                                        progressBlock:progressBlock];
+                                                                  httpMethod:httpRequestMethod
+                                                                 inputStream:inputStream
+                                                                     headers:additionalHeaders
+                                                               bytesExpected:bytesExpected
+                                                                     session:session
+                                                             completionBlock:completionBlock
+                                                               progressBlock:progressBlock];
         if (request){
             cmisRequest.httpRequest = request;
         }
@@ -150,9 +150,9 @@ completionBlock:(void (^)(CMISHttpRespon
                                                                  inputStream:inputStream
                                                                      headers:additionalHeaders
                                                                bytesExpected:bytesExpected
-                                                      authenticationProvider:session.authenticationProvider
-                                                              startData:startData
-                                                                    endData:endData
+                                                                     session:session
+                                                                   startData:startData
+                                                                     endData:endData
                                                            useBase64Encoding:useBase64Encoding
                                                              completionBlock:completionBlock
                                                                progressBlock:progressBlock];
@@ -185,7 +185,7 @@ completionBlock:(void (^)(CMISHttpRespon
                                                                       httpMethod:httpRequestMethod
                                                                   outputFilePath:outputFilePath
                                                                    bytesExpected:bytesExpected
-                                                          authenticationProvider:session.authenticationProvider
+                                                                         session:session
                                                                  completionBlock:completionBlock
                                                                    progressBlock:progressBlock];
         if (request) {
@@ -238,14 +238,14 @@ completionBlock:(void (^)(CMISHttpRespon
                                                                                   session:session];
         
         CMISHttpDownloadRequest* request = [CMISHttpDownloadRequest startRequest:urlRequest
-                                                             httpMethod:httpRequestMethod
-                                                           outputStream:outputStream
-                                                          bytesExpected:bytesExpected
-                                                                 offset:offset
-                                                                 length:length
-                                                 authenticationProvider:session.authenticationProvider
-                                                        completionBlock:completionBlock
-                                                          progressBlock:progressBlock];
+                                                                      httpMethod:httpRequestMethod
+                                                                    outputStream:outputStream
+                                                                   bytesExpected:bytesExpected
+                                                                          offset:offset
+                                                                          length:length
+                                                                         session:session
+                                                                 completionBlock:completionBlock
+                                                                   progressBlock:progressBlock];
         if (request) {
             cmisRequest.httpRequest = request;
         }

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.h?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.h Fri Dec 12
11:47:38 2014
@@ -38,35 +38,35 @@
  * completionBlock returns a CMISHttpResponse object or nil if unsuccessful
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                            outputStream:(NSOutputStream*)outputStream
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+      outputStream:(NSOutputStream*)outputStream
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
 
 /** starts a URL request for download with a given offset and or length. Data are written
to the provided output stream
  * completionBlock returns a CMISHttpResponse object or nil if unsuccessful
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                            outputStream:(NSOutputStream*)outputStream
-                           bytesExpected:(unsigned long long)bytesExpected
-                                  offset:(NSDecimalNumber*)offset
-                                  length:(NSDecimalNumber*)length
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+      outputStream:(NSOutputStream*)outputStream
+     bytesExpected:(unsigned long long)bytesExpected
+            offset:(NSDecimalNumber*)offset
+            length:(NSDecimalNumber*)length
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
 
 /** starts a URL request for download. Data is written to the provided file path.
  * completionBlock returns a CMISHttpResponse object or nil if unsuccessful
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                          outputFilePath:(NSString *)outputFilePath
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+    outputFilePath:(NSString *)outputFilePath
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
 
 @end

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.m?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpDownloadRequest.m Fri Dec 12
11:47:38 2014
@@ -38,40 +38,40 @@
 @implementation CMISHttpDownloadRequest
 
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                            outputStream:(NSOutputStream*)outputStream
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+      outputStream:(NSOutputStream*)outputStream
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock
 {
     return [CMISHttpDownloadRequest startRequest:urlRequest
-                               httpMethod:httpRequestMethod
-                             outputStream:outputStream
-                            bytesExpected:bytesExpected
-                                   offset:nil
-                                   length:nil
-                   authenticationProvider:authenticationProvider
-                          completionBlock:completionBlock
-                            progressBlock:progressBlock];
+                                      httpMethod:httpRequestMethod
+                                    outputStream:outputStream
+                                   bytesExpected:bytesExpected
+                                          offset:nil
+                                          length:nil
+                                         session:session
+                                 completionBlock:completionBlock
+                                   progressBlock:progressBlock];
 }
 
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                            outputStream:(NSOutputStream*)outputStream
-                           bytesExpected:(unsigned long long)bytesExpected
-                                  offset:(NSDecimalNumber*)offset
-                                  length:(NSDecimalNumber*)length
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+      outputStream:(NSOutputStream*)outputStream
+     bytesExpected:(unsigned long long)bytesExpected
+            offset:(NSDecimalNumber*)offset
+            length:(NSDecimalNumber*)length
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock
 {
     CMISHttpDownloadRequest *httpRequest = [[self alloc] initWithHttpMethod:httpRequestMethod
                                                             completionBlock:completionBlock
                                                               progressBlock:progressBlock];
     httpRequest.outputStream = outputStream;
     httpRequest.bytesExpected = bytesExpected;
-    httpRequest.authenticationProvider = authenticationProvider;
+    httpRequest.session = session;
     
     //range
     if ((offset != nil) || (length != nil)) {
@@ -96,19 +96,19 @@
 }
 
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                          outputFilePath:(NSString *)outputFilePath
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+    outputFilePath:(NSString *)outputFilePath
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
 {
     CMISHttpDownloadRequest *httpRequest = [[self alloc] initWithHttpMethod:httpRequestMethod
                                                             completionBlock:completionBlock
                                                               progressBlock:progressBlock];
     httpRequest.outputFilePath = outputFilePath;
     httpRequest.bytesExpected = bytesExpected;
-    httpRequest.authenticationProvider = authenticationProvider;
+    httpRequest.session = session;
     
     if (![httpRequest startRequest:urlRequest]) {
         httpRequest = nil;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.h?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.h Fri Dec 12 11:47:38
2014
@@ -32,7 +32,7 @@
 @property (nonatomic, strong) NSMutableData *responseBody;
 @property (nonatomic, strong) NSDictionary *additionalHeaders;
 @property (nonatomic, strong) NSHTTPURLResponse *response;
-@property (nonatomic, strong) id<CMISAuthenticationProvider> authenticationProvider;
+@property (nonatomic, strong) CMISBindingSession *session;
 @property (nonatomic, copy) void (^completionBlock)(CMISHttpResponse *httpResponse, NSError
*error);
 
 /**
@@ -43,11 +43,11 @@
  * completionBlock returns a CMISHTTPResponse object or nil if unsuccessful
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                      httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                     requestBody:(NSData*)requestBody
-                         headers:(NSDictionary*)additionalHeaders
-          authenticationProvider:(id<CMISAuthenticationProvider>)authenticationProvider
-                 completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+       requestBody:(NSData*)requestBody
+           headers:(NSDictionary*)additionalHeaders
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock;
 
 /**
  * initialises with a specified HTTP method

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.m?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpRequest.m Fri Dec 12 11:47:38
2014
@@ -22,6 +22,7 @@
 #import "CMISErrors.h"
 #import "CMISLog.h"
 #import "CMISReachability.h"
+#import "CMISConstants.h"
 
 //Exception names as returned in the <!--exception> tag
 NSString * const kCMISExceptionInvalidArgument         = @"invalidArgument";
@@ -43,17 +44,17 @@ NSString * const kCMISExceptionVersionin
 
 
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                      httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                     requestBody:(NSData*)requestBody
-                         headers:(NSDictionary*)additionalHeaders
-          authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                 completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+       requestBody:(NSData*)requestBody
+           headers:(NSDictionary*)additionalHeaders
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
 {
     CMISHttpRequest *httpRequest = [[self alloc] initWithHttpMethod:httpRequestMethod
                                                     completionBlock:completionBlock];
     httpRequest.requestBody = requestBody;
     httpRequest.additionalHeaders = additionalHeaders;
-    httpRequest.authenticationProvider = authenticationProvider;
+    httpRequest.session = session;
     
     if (![httpRequest startRequest:urlRequest]) {
         httpRequest = nil;
@@ -77,8 +78,19 @@ NSString * const kCMISExceptionVersionin
 
 - (BOOL)startRequest:(NSMutableURLRequest*)urlRequest
 {
+    // check network reachability (unless it's disabled) and return early if appropriate
+    id checkNetworkReachability = [self.session objectForKey:kCMISSessionParameterCheckNetworkReachability];
+    if (!checkNetworkReachability || [checkNetworkReachability boolValue]) {
+        CMISReachability *reachability = [CMISReachability networkReachability];
+        if (!reachability.hasNetworkConnection) {
+            NSError *noConnectionError = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeNoNetworkConnection
detailedDescription:kCMISErrorDescriptionNoNetworkConnection];
+            [self URLSession:self.urlSession task:self.sessionTask didCompleteWithError:noConnectionError];
+            return NO;
+        }
+    }
+    
     BOOL startedRequest = NO;
-
+    
     if (self.requestBody) {
         if ([CMISLog sharedInstance].logLevel == CMISLogLevelTrace) {
             CMISLogTrace(@"Request body: %@", [[NSString alloc] initWithData:self.requestBody
encoding:NSUTF8StringEncoding]);
@@ -87,7 +99,7 @@ NSString * const kCMISExceptionVersionin
         [urlRequest setHTTPBody:self.requestBody];
     }
     
-    [self.authenticationProvider.httpHeadersToApply enumerateKeysAndObjectsUsingBlock:^(NSString
*headerName, NSString *header, BOOL *stop) {
+    [self.session.authenticationProvider.httpHeadersToApply enumerateKeysAndObjectsUsingBlock:^(NSString
*headerName, NSString *header, BOOL *stop) {
         [urlRequest addValue:header forHTTPHeaderField:headerName];
         if ([CMISLog sharedInstance].logLevel == CMISLogLevelTrace) {
             CMISLogTrace(@"Added header: %@ with value: %@", headerName, header);
@@ -101,24 +113,39 @@ NSString * const kCMISExceptionVersionin
         }
     }];
     
+    // determine the type of session configuration to create
+    NSURLSessionConfiguration *sessionConfiguration = nil;
+    id useBackgroundSession = [self.session objectForKey:kCMISSessionParameterUseBackgroundNetworkSession];
+    if (useBackgroundSession && [useBackgroundSession boolValue]) {
+        // get session and container identifiers from session
+        NSString *backgroundId = [self.session objectForKey:kCMISSessionParameterBackgroundNetworkSessionId
+                                               defaultValue:kCMISDefaultBackgroundNetworkSessionId];
+        NSString *containerId = [self.session objectForKey:kCMISSessionParameterBackgroundNetworkSessionSharedContainerId
+                                              defaultValue:kCMISDefaultBackgroundNetworkSessionSharedContainerId];
+        
+        // use the background session configuration, cache settings and timeout will be provided
by the request object
+        sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundId];
+        sessionConfiguration.sharedContainerIdentifier = containerId;
+        
+        CMISLogDebug(@"Using background network session with identifier '%@' and shared container
'%@'",
+                     backgroundId, containerId);
+    }
+    else {
+        // use the default session configuration, cache settings and timeout will be provided
by the request object
+        sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
+    }
+    
     // create session and task
-    self.urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
-                                                    delegate:self
-                                               delegateQueue:nil];
+    self.urlSession = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self
delegateQueue:nil];
     self.sessionTask = [self taskForRequest:urlRequest];
     
-    CMISReachability *reachability = [CMISReachability networkReachability];
-    
-    if (self.sessionTask && reachability.hasNetworkConnection) {
+    if (self.sessionTask) {
+        // start the task
         [self.sessionTask resume];
         startedRequest = YES;
-    } else if (!reachability.hasNetworkConnection) {
-        NSError *noConnectionError = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeNoNetworkConnection
detailedDescription:kCMISErrorDescriptionNoNetworkConnection];
-        [self URLSession:self.urlSession task:self.sessionTask didCompleteWithError:noConnectionError];
-    }
-    else {
+    } else {
         if (self.completionBlock) {
-            NSString *detailedDescription = [NSString stringWithFormat:@"Could not connect
to %@", urlRequest.URL];
+            NSString *detailedDescription = [NSString stringWithFormat:@"Could not create
network session for %@", urlRequest.URL];
             NSError *cmisError = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeConnection
detailedDescription:detailedDescription];
             self.completionBlock(nil, cmisError);
         }
@@ -155,7 +182,7 @@ NSString * const kCMISExceptionVersionin
 
 - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError
*)error
 {
-    [self.authenticationProvider updateWithHttpURLResponse:self.response];
+    [self.session.authenticationProvider updateWithHttpURLResponse:self.response];
 
     if (self.completionBlock) {
         
@@ -209,7 +236,7 @@ NSString * const kCMISExceptionVersionin
 
 - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge
*)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential
*))completionHandler
 {
-    [self.authenticationProvider didReceiveChallenge:challenge completionHandler:completionHandler];
+    [self.session.authenticationProvider didReceiveChallenge:challenge completionHandler:completionHandler];
 }
 
 - (BOOL)checkStatusCodeForResponse:(CMISHttpResponse *)response httpRequestMethod:(CMISHttpRequestMethod)httpRequestMethod
error:(NSError **)error

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.h?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.h Fri Dec 12 11:47:38
2014
@@ -30,28 +30,28 @@
  * completionBlock returns CMISHttpResponse instance or nil if unsuccessful
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                             inputStream:(NSInputStream*)inputStream
-                                 headers:(NSDictionary*)additionalHeaders
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+       inputStream:(NSInputStream*)inputStream
+           headers:(NSDictionary*)additionalHeaders
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock;
 
 /**
  * starts a URL request with a provided input stream. The input stream has to point to the
raw NON-encoded data set. This method will first write the 
  * provided start data, afterwards the content of the input stream (optionally encoding it
as base64) and then the provided end data.
  */
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                              httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                             inputStream:(NSInputStream*)sourceInputStream
-                                 headers:(NSDictionary*)additionalHeaders
-                           bytesExpected:(unsigned long long)bytesExpected
-                  authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                               startData:(NSData *)startData
-                                 endData:(NSData *)endData
-                       useBase64Encoding:(BOOL)useBase64Encoding
-                         completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                           progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned
long long bytesTotal))progressBlock;
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+       inputStream:(NSInputStream*)sourceInputStream
+           headers:(NSDictionary*)additionalHeaders
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+         startData:(NSData *)startData
+           endData:(NSData *)endData
+ useBase64Encoding:(BOOL)useBase64Encoding
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock;
 
 @end

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m?rev=1644862&r1=1644861&r2=1644862&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m Fri Dec 12 11:47:38
2014
@@ -102,13 +102,13 @@ const NSUInteger kRawBufferSize = 24576;
 @implementation CMISHttpUploadRequest
 
 + (id)startRequest:(NSMutableURLRequest *)urlRequest
-                            httpMethod:(CMISHttpRequestMethod)httpRequestMethod
-                           inputStream:(NSInputStream*)inputStream
-                               headers:(NSDictionary*)additionalHeaders
-                         bytesExpected:(unsigned long long)bytesExpected
-                authenticationProvider:(id<CMISAuthenticationProvider>) authenticationProvider
-                       completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError
*error))completionBlock
-                         progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned
long long bytesTotal))progressBlock
+        httpMethod:(CMISHttpRequestMethod)httpRequestMethod
+       inputStream:(NSInputStream*)inputStream
+           headers:(NSDictionary*)additionalHeaders
+     bytesExpected:(unsigned long long)bytesExpected
+           session:(CMISBindingSession *)session
+   completionBlock:(void (^)(CMISHttpResponse *httpResponse, NSError *error))completionBlock
+     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
 {
     CMISHttpUploadRequest *httpRequest = [[self alloc] initWithHttpMethod:httpRequestMethod
                                                           completionBlock:completionBlock
@@ -116,7 +116,7 @@ const NSUInteger kRawBufferSize = 24576;
     httpRequest.inputStream = inputStream;
     httpRequest.additionalHeaders = additionalHeaders;
     httpRequest.bytesExpected = bytesExpected;
-    httpRequest.authenticationProvider = authenticationProvider;
+    httpRequest.session = session;
     httpRequest.useCombinedInputStream = NO;
     httpRequest.combinedInputStream = nil;
     httpRequest.encoderStream = nil;
@@ -133,7 +133,7 @@ const NSUInteger kRawBufferSize = 24576;
        inputStream:(NSInputStream *)inputStream
            headers:(NSDictionary *)additionalHeaders
      bytesExpected:(unsigned long long)bytesExpected
-authenticationProvider:(id<CMISAuthenticationProvider>)authenticationProvider
+           session:(CMISBindingSession *)session
          startData:(NSData *)startData
            endData:(NSData *)endData
  useBase64Encoding:(BOOL)useBase64Encoding
@@ -151,7 +151,7 @@ authenticationProvider:(id<CMISAuthentic
     httpRequest.bytesExpected = bytesExpected;
     httpRequest.useCombinedInputStream = YES;
     httpRequest.base64Encoding = useBase64Encoding;
-    httpRequest.authenticationProvider = authenticationProvider;
+    httpRequest.session = session;
     
     [httpRequest prepareStreams];
     if (![httpRequest startRequest:urlRequest]) {



Mime
View raw message