Skip to content

Commit 48bcc48

Browse files
chore(client): do not parse responses with empty content-length
1 parent 3080718 commit 48bcc48

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
7070
const mediaType = contentType?.split(';')[0]?.trim();
7171
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
7272
if (isJSON) {
73+
const contentLength = response.headers.get('content-length');
74+
if (contentLength === '0') {
75+
// if there is no content we can't do anything
76+
return undefined as T;
77+
}
78+
7379
const json = await response.json();
7480

7581
debug('response', response.status, response.url, response.headers, json);

0 commit comments

Comments
 (0)