cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: CB-5588 iOS: Add response headers to upload result
Date Mon, 10 Feb 2014 19:59:34 GMT
Updated Branches:
  refs/heads/dev 651460fb6 -> 28fb0a7c4


CB-5588 iOS: Add response headers to upload result

This change adds the HTTP response headers to the result for successful
uploads.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/28fb0a7c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/28fb0a7c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/28fb0a7c

Branch: refs/heads/dev
Commit: 28fb0a7c4d07278d2f765f6762fb8b1a6fd1d2e4
Parents: 651460f
Author: Daniel Heffernan <daniel@cookpad.com>
Authored: Mon Feb 10 14:58:37 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 10 14:58:37 2014 -0500

----------------------------------------------------------------------
 src/ios/CDVFileTransfer.h | 1 +
 src/ios/CDVFileTransfer.m | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/28fb0a7c/src/ios/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVFileTransfer.h b/src/ios/CDVFileTransfer.h
index aa1cf9e..1ce7abe 100644
--- a/src/ios/CDVFileTransfer.h
+++ b/src/ios/CDVFileTransfer.h
@@ -64,6 +64,7 @@ extern NSString* const kOptionsKeyCookie;
 - (void)cancelTransfer:(NSURLConnection*)connection;
 
 @property (strong) NSMutableData* responseData; // atomic
+@property (nonatomic, strong) NSDictionary* responseHeaders;
 @property (nonatomic, strong) CDVFileTransfer* command;
 @property (nonatomic, assign) CDVFileTransferDirection direction;
 @property (nonatomic, strong) NSURLConnection* connection;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/28fb0a7c/src/ios/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 1ae0730..e35e2fe 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -513,7 +513,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
 
 @implementation CDVFileTransferDelegate
 
-@synthesize callbackId, connection = _connection, source, target, responseData, command,
bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle;
+@synthesize callbackId, connection = _connection, source, target, responseData, responseHeaders,
command, bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle;
 
 - (void)connectionDidFinishLoading:(NSURLConnection*)connection
 {
@@ -532,6 +532,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
             uploadResult = [NSMutableDictionary dictionaryWithCapacity:3];
             if (uploadResponse != nil) {
                 [uploadResult setObject:uploadResponse forKey:@"response"];
+                [uploadResult setObject:self.responseHeaders forKey:@"headers"];
             }
             [uploadResult setObject:[NSNumber numberWithLongLong:self.bytesTransfered] forKey:@"bytesSent"];
             [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
@@ -600,6 +601,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
 
         self.responseCode = [httpResponse statusCode];
         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
             // bytesExpected will be updated when that response is returned


Mime
View raw message