diff --git a/CHANGELOG.md b/CHANGELOG.md index f492f0e..dc038ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v1.7.1 + +- Fixed #36: setting basic authentication not working correctly +- Fixed #35: Android headers not normalized (not returned in lowercase) + ## v1.7.0 - Feature #24: "setHeader" allows configuring headers for specified host diff --git a/README.md b/README.md index 520980d..4943a51 100644 --- a/README.md +++ b/README.md @@ -128,13 +128,15 @@ Remove all cookies associated with a given URL. Execute a POST request. Takes a URL, data, and headers. #### success -The success function receives a response object with 3 properties: status, data, and headers. Status is the HTTP response code. Data is the response from the server as a string. Headers is an object with the headers. Here's a quick example: +The success function receives a response object with 3 properties: status, data, and headers. **status** is the HTTP response code as numeric value. **data** is the response from the server as a string. **headers** is an object with the headers. The keys of the returned object are the header names and the values are the respective header values. All header names are lowercase. + +Here's a quick example: { status: 200, data: "{'id': 12, 'message': 'test'}", headers: { - "Content-Length": "247" + "content-length": "247" } } @@ -163,13 +165,15 @@ Most apis will return JSON meaning you'll want to parse the data like in the exa #### failure -The error function receives a response object with 3 properties: status, error and headers. Status is the HTTP response code. Error is the error response from the server as a string. Headers is an object with the headers. Here's a quick example: +The error function receives a response object with 3 properties: status, error and headers. **status** is the HTTP response code as numeric value. **error** is the error response from the server as a string. **headers** is an object with the headers. The keys of the returned object are the header names and the values are the respective header values. All header names are lowercase. + +Here's a quick example: { status: 403, error: "Permission denied", headers: { - "Content-Length": "247" + "content-length": "247" } } diff --git a/src/android/com/synconset/cordovahttp/CordovaHttp.java b/src/android/com/synconset/cordovahttp/CordovaHttp.java index 4efad65..3cf3be9 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttp.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttp.java @@ -150,7 +150,7 @@ abstract class CordovaHttp { List value = entry.getValue(); if ((key != null) && (!value.isEmpty())) { - filteredHeaders.put(key, TextUtils.join(", ", value)); + filteredHeaders.put(key.toLowerCase(), TextUtils.join(", ", value)); } }