diff --git a/lib/restler.js b/lib/restler.js index fda78fc..7b97a4d 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -46,10 +46,13 @@ function Request(uri, options) { if (!this.options.method) this.options.method = (this.options.data) ? 'POST' : 'GET'; if (typeof this.options.followRedirects == 'undefined') this.options.followRedirects = true; + // set the querystring to the override if it is provided + if (!this.querystring) this.querystring = this.options.querystring ? this.options.querystring : qs; + // stringify query given in options of not given in URL if (this.options.query && !this.url.query) { if (typeof this.options.query == 'object') - this.url.query = qs.stringify(this.options.query); + this.url.query = this.querystring.stringify(this.options.query); else this.url.query = this.options.query; } @@ -66,7 +69,7 @@ function Request(uri, options) { } } else { if (typeof this.options.data == 'object') { - this.options.data = qs.stringify(this.options.data); + this.options.data = this.querystring.stringify(this.options.data); this.headers['Content-Type'] = 'application/x-www-form-urlencoded'; this.headers['Content-Length'] = this.options.data.length; }