From c14884b76b2fbda5a09468b0844841cefc3c24ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Sa=CC=81nchez?= Date: Wed, 6 Aug 2014 13:33:44 +0200 Subject: [PATCH 1/2] New option: forceResponseCharset --- lib/restler.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/restler.js b/lib/restler.js index 715845a..ee75d41 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -172,8 +172,13 @@ mixin(Request.prototype, { }, _iconv: function(body, response) { var charset = response.headers['content-type']; - if (charset) { - charset = /\bcharset=(.+)(?:;|$)/i.exec(charset); + if (charset || this.options.forceResponseCharset) { + if (this.options.forceResponseCharset) { + charset = this.options.forceResponseCharset; + } + else { + charset = /\bcharset=(.+)(?:;|$)/i.exec(charset); + } if (charset) { charset = charset[1].trim().toUpperCase(); if (charset != 'UTF-8') { From 4ff5868165fb0c910f8e4915200b05787b2079eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Sa=CC=81nchez?= Date: Wed, 6 Aug 2014 13:58:43 +0200 Subject: [PATCH 2/2] New option: forceResponseCharset --- lib/restler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/restler.js b/lib/restler.js index ee75d41..c895582 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -174,7 +174,7 @@ mixin(Request.prototype, { var charset = response.headers['content-type']; if (charset || this.options.forceResponseCharset) { if (this.options.forceResponseCharset) { - charset = this.options.forceResponseCharset; + charset = [null, this.options.forceResponseCharset]; } else { charset = /\bcharset=(.+)(?:;|$)/i.exec(charset);