Skip to content

Commit 55dd751

Browse files
author
Sefa Ilkimen
committed
fix silkimen#92: headers not deserialized on platform "browser"
1 parent af239d3 commit 55dd751

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.11.1
4+
5+
- Fixed #92: headers not deserialized on platform "browser"
6+
37
## 1.11.0
48

59
- Feature #77: allow overriding global settings for each single request

src/browser/cordova-http-plugin.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,27 @@ function serializeParams(params) {
3737
}).join('&');
3838
}
3939

40+
function deserializeResponseHeaders(headers) {
41+
var headerMap = {};
42+
var arr = headers.trim().split(/[\r\n]+/);
43+
44+
arr.forEach(function (line) {
45+
var parts = line.split(': ');
46+
var header = parts.shift().toLowerCase();
47+
var value = parts.join(': ');
48+
49+
headerMap[header] = value;
50+
});
51+
52+
return headerMap;
53+
}
54+
4055
function createXhrSuccessObject(xhr) {
4156
return {
4257
url: xhr.responseURL,
4358
status: xhr.status,
4459
data: helpers.getTypeOf(xhr.responseText) === 'String' ? xhr.responseText : xhr.response,
45-
headers: xhr.getAllResponseHeaders()
60+
headers: deserializeResponseHeaders(xhr.getAllResponseHeaders())
4661
};
4762
}
4863

@@ -136,7 +151,7 @@ var browserInterface = {
136151
put: function (success, failure, opts) {
137152
return sendRequest('put', true, opts, success, failure);
138153
},
139-
patch: function (success, failure, opts) {
154+
patch: function (success, failure, opts) {
140155
return sendRequest('patch', true, opts, success, failure);
141156
},
142157
delete: function (success, failure, opts) {

0 commit comments

Comments
 (0)