Skip to content

Commit

Permalink
fix: compatible with qq browser on ios, close unjs#294
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Feb 27, 2024
1 parent 244fb6a commit 6da36df
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
return await onError(context);
}

const hasBody =
context.response.body &&
const allowParse =
!nullBodyResponses.has(context.response.status) &&
context.options.method !== "HEAD";
if (hasBody) {
if (allowParse) {
const responseType =
(context.options.parseResponse
? "json"
Expand All @@ -189,7 +188,12 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
break;
}
case "stream": {
context.response._data = context.response.body;
context.response._data =
context.response.body ||
// @ts-ignore Compatible with QQ Browser on iOS
context.response._bodyInit?.stream() ||
// @ts-ignore Compatible with QQ Browser on iOS
context.response._bodyBlob?.stream();
break;
}
default: {
Expand Down

0 comments on commit 6da36df

Please sign in to comment.