You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/03/22 02:00:11 UTC

[38/50] incubator-weex git commit: * [ios] fix stream response type bug

* [ios] fix stream response type bug


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/bbcc2db0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/bbcc2db0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/bbcc2db0

Branch: refs/heads/0.12-dev
Commit: bbcc2db027630f32c609a211871bf21a0702bea0
Parents: 29b0464
Author: acton393 <zh...@gmail.com>
Authored: Mon Mar 20 16:02:21 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Mon Mar 20 16:02:21 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bbcc2db0/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
index c23680d..d35f7d0 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
@@ -119,7 +119,9 @@ WX_EXPORT_METHOD(@selector(fetch:callback:progressCallback:))
     
     //parse responseType
     NSString *responseType = [options objectForKey:@"type"];
-    [callbackRsp setObject:responseType?:@"JSON" forKey:@"responseType"];
+    if ([responseType isKindOfClass:[NSString class]]) {
+        [callbackRsp setObject:responseType? responseType.lowercaseString:@"" forKey:@"responseType"];
+    }
     
     //parse timeout
     if ([options valueForKey:@"timeout"]){
@@ -195,8 +197,8 @@ WX_EXPORT_METHOD(@selector(fetch:callback:progressCallback:))
     NSString *responseData = [self _stringfromData:data encode:((NSHTTPURLResponse*)response).textEncodingName];
     NSString * responseType = [callbackRsp objectForKey:@"responseType"];
     [callbackRsp removeObjectForKey:@"responseType"];
-    if (responseType) {
-        
+    if ([responseType isEqualToString:@"json"] || [responseType isEqualToString:@"jsonp"]) {
+        //handle json format
         if ([responseType isEqualToString:@"jsonp"]) {
             //TODO: to be more elegant
             NSUInteger start = [responseData rangeOfString:@"("].location + 1 ;
@@ -211,6 +213,7 @@ WX_EXPORT_METHOD(@selector(fetch:callback:progressCallback:))
         }
         
     } else {
+        // return original Data
         if (responseData) {
             [callbackRsp setObject:responseData forKey:@"data"];
         }