Fix HTTP empty responses
All checks were successful
Build / Build NPM Project (push) Successful in 37s
Build / Tag Version (push) Successful in 8s
Build / Publish Documentation (push) Successful in 34s

This commit is contained in:
Zakary Timson 2025-04-13 10:16:50 -04:00
parent f952abc95a
commit 9a0f32323e
2 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.23.21", "version": "0.23.22",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",
@ -14,9 +14,9 @@
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs", "import": "./dist/index.mjs",
"require": "./dist/index.cjs", "require": "./dist/index.cjs"
"types": "./dist/index.d.ts"
} }
}, },
"scripts": { "scripts": {
@ -34,7 +34,7 @@
"typedoc": "^0.26.7", "typedoc": "^0.26.7",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vite": "^5.0.12", "vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2" "vite-plugin-dts": "^4.5.3"
}, },
"files": [ "files": [
"dist" "dist"

View File

@ -30,7 +30,13 @@ class HttpResponse<T = any> extends Response {
url!: string; url!: string;
constructor(resp: Response, stream: ReadableStream) { constructor(resp: Response, stream: ReadableStream) {
super(stream, {headers: resp.headers, status: resp.status, statusText: resp.statusText}); const body = [204, 205, 304].includes(resp.status) ? null : stream;
super(body, {
headers: resp.headers,
status: resp.status,
statusText: resp.statusText,
});
this.ok = resp.ok; this.ok = resp.ok;
this.redirected = resp.redirected; this.redirected = resp.redirected;
this.type = resp.type; this.type = resp.type;