Skip to content

Commit

Permalink
don't clone responses in serialization functions (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban authored Dec 7, 2021
1 parent 3f4a9c6 commit 8be210f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion @stellar/anchor-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"jsonschema": "^1.4.0",
"jsonwebtoken": "^8.5.1",
"node-fetch": "^2.6.1",
"stellar-sdk": "~8.2.1",
"stellar-sdk": "~8.2.5",
"toml": "^3.0.0",
"tslib": "^2.2.0",
"yargs": "^16.2.0"
Expand Down
12 changes: 3 additions & 9 deletions server/src/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ async function serializeNetworkCall(
if (networkCall.request.body) {
const contentType = networkCall.request.headers.get("Content-Type") || "";
if (contentType.includes("application/json")) {
serializedNetworkCall.request.body = await networkCall.request
.clone()
.json();
serializedNetworkCall.request.body = await networkCall.request.json();
} else if (contentType.includes("multipart/form-data")) {
// TODO
} else if (contentType.includes("application/x-www-form-urlencoded")) {
Expand All @@ -147,13 +145,9 @@ async function serializeNetworkCall(
const contentType =
networkCall.response.headers.get("Content-Type") || "";
if (contentType.includes("application/json")) {
serializedNetworkCall.response.body = await networkCall.response
.clone()
.json();
serializedNetworkCall.response.body = await networkCall.response.json();
} else {
serializedNetworkCall.response.body = await networkCall.response
.clone()
.text();
serializedNetworkCall.response.body = await networkCall.response.text();
}
}
}
Expand Down

0 comments on commit 8be210f

Please sign in to comment.