diff --git a/CHANGELOG.md b/CHANGELOG.md index 2528aa1..25832d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.10.0 + +- Feature #34: add new serializer "utf8" sending utf-8 encoded plain text (thanks robertocapuano) + ## 1.9.1 - Fixed #45: does not encode arrays correctly as HTTP GET parameter on Android diff --git a/README.md b/README.md index f760cad..b56490a 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ This sets up all future requests to use Basic HTTP authentication with the given cordova.plugin.http.useBasicAuth('user', 'password'); ``` -### setHeader +### setHeader Set a header for all future requests to a specified host. Takes a hostname, a header and a value (must be a string value). ```js @@ -101,11 +101,14 @@ Set the data serializer which will be used for all future PATCH, POST and PUT re cordova.plugin.http.setDataSerializer('urlencoded'); ``` -You can choose one of these two: +You can choose one of these: * `urlencoded`: send data as url encoded content in body (content type "application/x-www-form-urlencoded") * `json`: send data as JSON encoded content in body (content type "application/json") +* `utf8`: send data as plain UTF8 encoded string in body (content type "plain/text") -Caution: `urlencoded` does not support serializing deep structures whereas `json` does. +You can also override the default content type headers by specifying your own headers (see [setHeader](#setHeader)). + +__Caution__: `urlencoded` does not support serializing deep structures whereas `json` does. ### setRequestTimeout Set how long to wait for a request to respond, in seconds. diff --git a/www/helpers.js b/www/helpers.js index c989e40..ba65855 100644 --- a/www/helpers.js +++ b/www/helpers.js @@ -2,7 +2,7 @@ var pluginId = module.id.slice(0, module.id.lastIndexOf('.')); var cookieHandler = require(pluginId + '.cookie-handler'); var messages = require(pluginId + '.messages'); -var validSerializers = ['urlencoded', 'json', 'utf8' ]; +var validSerializers = [ 'urlencoded', 'json', 'utf8' ]; module.exports = { b64EncodeUnicode: b64EncodeUnicode,