Skip to content

Commit

Permalink
revert: "cloud.ApiRequest.body is an empty string for GET requests" (
Browse files Browse the repository at this point in the history
…#6575)

Reverts #6572
  • Loading branch information
eladcon authored May 28, 2024
1 parent 1d09a8b commit 71bff40
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/tests/sdk_tests/api/get.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let body = "ok!";
api.get("/path", inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
assert(req.method == cloud.HttpMethod.GET);
assert(req.path == "/path");
assert(req.body == nil);
assert(req.body?.length == 0);
assert(req.headers?.get("content-type") == "application/json");

return cloud.ApiResponse {
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/sdk_tests/api/options.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let path = "/path";
api.options(path, inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
assert(req.method == cloud.HttpMethod.OPTIONS);
assert(req.path == path);
assert(req.body == nil);
assert(req.body?.length == 0);

return cloud.ApiResponse {
status: 204
Expand All @@ -19,7 +19,7 @@ api.options(path, inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
api.head(path, inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
assert(req.method == cloud.HttpMethod.HEAD);
assert(req.path == path);
assert(req.body == nil);
assert(req.body?.length == 0);

return cloud.ApiResponse {
status: 204
Expand Down
2 changes: 1 addition & 1 deletion libs/wingsdk/src/target-sim/api.inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class Api
function transformRequest(req: express.Request): ApiRequest {
return {
headers: sanitizeParamLikeObject(req.headers),
body: Object.keys(req.body).length > 0 ? req.body : undefined,
body: Object.keys(req.body).length > 0 ? req.body : "",
method: parseHttpMethod(req.method),
path: req.path,
query: sanitizeParamLikeObject(req.query as any),
Expand Down
Loading

0 comments on commit 71bff40

Please sign in to comment.