From 79db97edd0e156332cfe17a8ea69c11cadb32d83 Mon Sep 17 00:00:00 2001 From: Greg Inman Date: Tue, 9 Dec 2014 12:29:57 -0600 Subject: [PATCH 1/2] avoid re-encoding request body on retry --- lib/restler.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/restler.js b/lib/restler.js index 715845a..25c4191 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -56,7 +56,9 @@ function Request(uri, options) { } } else { if (typeof this.options.data == 'object') { - this.options.data = qs.stringify(this.options.data); + if (!(this.options.data instanceof Buffer)) { + this.options.data = qs.stringify(this.options.data); + } this.headers['Content-Type'] = 'application/x-www-form-urlencoded'; this.headers['Content-Length'] = this.options.data.length; } From 3546dce9ae4e42305e7d17bd74ca009caecb3928 Mon Sep 17 00:00:00 2001 From: Greg Inman Date: Fri, 12 Dec 2014 14:45:15 -0600 Subject: [PATCH 2/2] content type header was being set wrong on retry --- lib/restler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/restler.js b/lib/restler.js index 25c4191..3ae30d5 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -58,8 +58,8 @@ function Request(uri, options) { if (typeof this.options.data == 'object') { if (!(this.options.data instanceof Buffer)) { this.options.data = qs.stringify(this.options.data); + this.headers['Content-Type'] = 'application/x-www-form-urlencoded'; } - this.headers['Content-Type'] = 'application/x-www-form-urlencoded'; this.headers['Content-Length'] = this.options.data.length; } if (typeof this.options.data == 'string') {