Messing around with http decoding
This commit is contained in:
parent
26c6084052
commit
d587b92ea4
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.14.9",
|
"version": "0.14.10",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
15
src/http.ts
15
src/http.ts
@ -104,18 +104,13 @@ export class Http {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = new Response(stream);
|
resp.data = new Response(stream);
|
||||||
resp.blob = data.blob;
|
|
||||||
resp.formData = data.formData;
|
|
||||||
resp.json = data.json;
|
|
||||||
resp.text = data.text;
|
|
||||||
|
|
||||||
if(opts.decode !== false) {
|
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('application')) resp.data = <T>await resp.data.blob();
|
||||||
else if(content?.includes('form')) resp.data = <T>await data.formData();
|
else if(content?.includes('form')) resp.data = <T>await resp.data.formData();
|
||||||
else if(content?.includes('json')) resp.data = <T>await data.json();
|
else if(content?.includes('json')) resp.data = <T>await resp.data.json();
|
||||||
else if(content?.includes('text')) resp.data = <T>await data.text();
|
else if(content?.includes('text')) resp.data = <T>await resp.data.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resp.ok) res(resp);
|
if(resp.ok) res(resp);
|
||||||
|
Loading…
Reference in New Issue
Block a user