Compare commits

..

2 Commits

Author SHA1 Message Date
535fc0271e Messing around with http decoding
All checks were successful
Build / Build NPM Project (push) Successful in 24s
Build / Tag Version (push) Successful in 7s
2024-08-13 15:41:47 -04:00
d587b92ea4 Messing around with http decoding
All checks were successful
Build / Build NPM Project (push) Successful in 24s
Build / Tag Version (push) Successful in 7s
2024-08-13 15:38:20 -04:00
2 changed files with 7 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.14.9", "version": "0.14.11",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -104,18 +104,13 @@ export class Http {
} }
}); });
const data = new Response(stream); resp.data = new Response(stream);
resp.blob = data.blob; if(opts.decode == null || opts.decode) {
resp.formData = data.formData;
resp.json = data.json;
resp.text = data.text;
if(opts.decode !== false) {
const content = resp.headers.get('Content-Type')?.toLowerCase(); const content = resp.headers.get('Content-Type')?.toLowerCase();
if(content?.includes('application')) resp.data = <T>await data.blob(); if(content?.includes('form')) resp.data = <T>await resp.data.formData();
else if(content?.includes('form')) resp.data = <T>await data.formData(); else if(content?.includes('json')) resp.data = <T>await resp.data.json();
else if(content?.includes('json')) resp.data = <T>await data.json(); else if(content?.includes('text')) resp.data = <T>await resp.data.text();
else if(content?.includes('text')) resp.data = <T>await data.text(); else if(content?.includes('application')) resp.data = <T>await resp.data.blob();
} }
if(resp.ok) res(resp); if(resp.ok) res(resp);