unjs / ofetch

😱 A better fetch API. Works on node, browser and workers.
MIT License
4.1k stars 128 forks source link

Add file response type or the response headers to blob #350

Open pvasilek opened 9 months ago

pvasilek commented 9 months ago

Describe the feature

File downloading can parse a filename from the response header 'content-disposition'. As I see there is no way neither to get response headers nor the filenames. It may be also extra parameter for .then(($blob, $headers) => {}) Not sure if it will work as async onResponse({ request, response, options }) { console.log("[fetch response]", response, JSON.stringify(response.headers)) }, shows no headers at all.

Additional information

SeppeMarien commented 9 months ago

+1

valh1996 commented 8 months ago

+1

kingyue737 commented 8 months ago

ofetch.raw also returns a response with empty headers {}

pvasilek commented 8 months ago

It is not a library. New security features from browsers. I do not think it may be possible to make a fix.

Lpmvb commented 8 months ago

response.headers.get('content-disposition')