Skip to content

Commit

Permalink
* [android] fix get header:compitable with lower case header key
Browse files Browse the repository at this point in the history
  • Loading branch information
sospartan committed Aug 3, 2016
1 parent a9cc873 commit 5ebec75
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/http/WXStreamModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void onResponse(WXResponse response, Map<String, String> headers) {
WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callback,
(response == null || response.originalData == null) ? "{}" :
readAsString(response.originalData,
headers!=null?headers.get("Content-Type"):""
headers!=null?getHeader(headers,"Content-Type"):""
));
}
}, null);
Expand Down Expand Up @@ -360,7 +360,7 @@ public void onResponse(WXResponse response, Map<String, String> headers) {
resp.put("data", null);
} else {
String respData = readAsString(response.originalData,
headers!=null?headers.get("Content-Type"):""
headers!=null?getHeader(headers,"Content-Type"):""
);
resp.put("data",parseJson(respData,options.getType()));
}
Expand Down Expand Up @@ -393,6 +393,18 @@ Object parseJson(String data,Options.Type type){
}
}

static String getHeader(Map<String,String> headers,String key){
if(headers == null||key == null){
return null;
}
if(headers.containsKey(key)){
return headers.get(key);
}else{
return headers.get(key.toLowerCase());
}
}



static String readAsString(byte[] data,String cType){
String charset = "utf-8";
Expand Down

0 comments on commit 5ebec75

Please sign in to comment.