You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2017/11/22 00:26:31 UTC

[GitHub] maverickmishra closed pull request #193: CB-13466: (ios) Only use HEAD to get real length if content encoding ?

maverickmishra closed pull request #193: CB-13466: (ios) Only use HEAD to get real length if content encoding ?
URL: https://github.com/apache/cordova-plugin-file-transfer/pull/193
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index d0584ad..b053460 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -726,9 +726,20 @@ - (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLRespons
         self.bytesExpected = [response expectedContentLength];
         self.responseHeaders = [httpResponse allHeaderFields];
         if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode == 200) && (self.bytesExpected == NSURLResponseUnknownLength)) {
-            // Kick off HEAD request to server to get real length
+            BOOL gzip = NO;
+            for (NSString *key in [self.responseHeaders allKeys]) {
+                if ( [@"Content-Encoding" caseInsensitiveCompare:key] == NSOrderedSame ) {
+                    if ( [@"gzip" caseInsensitiveCompare:[self.responseHeaders objectForKey:key]] == NSOrderedSame ){
+                        gzip = YES;
+                    }
+                }
+            }
+
+            // Kick off HEAD request to server to get real length if content encoding is gzip
             // bytesExpected will be updated when that response is returned
-            self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self];
+            if ( gzip ) {
+                self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self];
+            }
         }
     } else if ([response.URL isFileURL]) {
         NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil];


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org