2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Adds option to specify character set in responses when using http adapter

This commit is contained in:
John Syrinek
2017-04-24 15:48:51 -05:00
parent f31317aeca
commit 7340c5d5fb
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -280,6 +280,10 @@ These are the available config options for making requests. Only the `url` is re
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
responseType: 'json', // default
// `responseEncoding` indicates encoding to use for decoding responses
// Note: Ignored for `responseType` of 'stream' or client-side requests
responseEncoding: 'utf8', // default
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
xsrfCookieName: 'XSRF-TOKEN', // default
+1 -1
View File
@@ -185,7 +185,7 @@ module.exports = function httpAdapter(config) {
stream.on('end', function handleStreamEnd() {
var responseData = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString('utf8');
responseData = responseData.toString(config.responseEncoding);
}
response.data = responseData;