feat: set headers in individual query and be able to write Buffer data for attachment download
See original GitHub issueDescribe the feature you’d like to request
Make the response a download request so browser can immediate initiate the download right away
e.g.
//res.header('Content-Disposition', `attachment; filename="${fileName}"`)
//res.header('Content-Type', fileType)
//const download = Buffer.from(fileData); // fileData is a string
//res.end(download)
Describe the solution you’d like to see
able to use res.header() right now res.header() will throw an error that the request has already been sent
same thing with res.end(), where right now it will throw circular json when it is simply a string
Desribe alternate solutions
I don’t know any viable ones, ideally the ones shown above in the solution makes the most sense and the most striaghtforward
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I’d be down to file a PR implementing this feature!
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to set a header for a HTTP GET request, and trigger file ...
There are two ways to download a file where the HTTP request requires that a header be set. The credit for the first...
Read more >umijs/umi-request: A request tool based on fetch. - GitHub
toLowerCase() === 'get' }, // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object...
Read more >HTTPie 3.2.1 (latest) docs
Each request item is simply a key/value pair separated with the following characters: : (headers), = (data field, e.g., JSON, form), := (raw...
Read more >Assistance with Importing CSV with headers on row 2
We have an integration from peoplesoft where data was emailed in with attachment, in xlsx format, that had the headers on row 2,...
Read more >HAProxy version 2.2.22 - Configuration Manual - GitHub Pages
In order to make this possible, HAProxy supports character escaping by ... Sets the path of the DeviceAtlas JSON data file to be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tested with various entry points with various results but one thing for sure, that setHeader didn’t throw any error anymore, very encouraging.
Trying to add custom header “TEST”: “test”
Tested on postman Result: it showed up in the response header field, hooray!!
Tested from browser calling the method using @trpc/client Result: no error but the header didn’t show up in the response header field when viewing from inspector, :\
It is very likely due to CORS, will need to check again
------------- update -------------
Weird, after CORS allowing all headers, the custom headers still didn’t show up.
Also, changing the CORS header somehow made postman not working anymore (request still succeeded but the custom header isn’t set), not sure why
------------- update -------------
sorry for the back and forth but I restarted the server a couple of times and suddenly the header shows up in the browser method now!!
I guess it works just sometimes it is unstable?? But it works now.
I appreciated the help, I guess header and writeHead both sends the requests implicitly?? I really don’t know the implementation details on but setHeader seems to work as expected.
Thanks again.
Look forward to the feature for content-type being available, that would be awesome.
Since I have gotten the feature I will close this one.
Thanks for sharing your process! ♥