Skip to content

Commit

Permalink
allow sending body for GET request of REST services (#2574)
Browse files Browse the repository at this point in the history
* allow sending body for GET request of REST services

* not set stringified empty object in body for rest json
  • Loading branch information
AllanZhengYP authored Mar 18, 2019
1 parent aca7cf9 commit f9ef9b6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-Paginator-b5c4816c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "Paginator",
"description": "fix the issue where paginator keys are ignored in GET requests"
}
9 changes: 6 additions & 3 deletions lib/protocol/rest_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ function populateBody(req) {
}
}
} else {
req.httpRequest.body = builder.build(req.params, input);
var body = builder.build(req.params, input);
if (body !== '{}') { //don't send empty object
req.httpRequest.body = body;
}
applyContentTypeHeader(req);
}
}
Expand All @@ -42,8 +45,8 @@ function applyContentTypeHeader(req, isBinary) {
function buildRequest(req) {
Rest.buildRequest(req);

// never send body payload on GET/HEAD/DELETE
if (['GET', 'HEAD', 'DELETE'].indexOf(req.httpRequest.method) < 0) {
// never send body payload on HEAD/DELETE
if (['HEAD', 'DELETE'].indexOf(req.httpRequest.method) < 0) {
populateBody(req);
}
}
Expand Down
17 changes: 16 additions & 1 deletion test/protocol/rest_json.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/services/cloudsearchdomain.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9ef9b6

Please sign in to comment.