cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] maverickmishra closed pull request #193: CB-13466: (ios) Only use HEAD to get real length if content encoding ?
Date Thu, 01 Jan 1970 00:00:00 GMT
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


Mime
View raw message