Skip to content

Commit

Permalink
fix: Remove JSON content type when body is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoyung committed Feb 17, 2023
1 parent ddc334b commit 8bff0fb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/http/http-native-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export class HttpNativeImpl extends BaseHttp implements Http {
headers.delete('Content-Type');
}

if (body == undefined && getContentType(headers) == 'application/json') {
// Since an empty string is not a valid JSON,
// if the body is empty and the content type is set to JSON,
// remove 'content-type:application/json' from headers
headers.delete('Content-Type');
}

const request = new Request(url, {
...requestInit,
headers,
Expand Down

0 comments on commit 8bff0fb

Please sign in to comment.