Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/restler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down