flawiddsouza / Restfox

Offline-First Minimalistic HTTP & Socket Testing Client for the Web & Desktop

Home Page:https://restfox.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save binary response as file: wrong parsing of "content-disposition" header

WolfgangHG opened this issue · comments

This is a followup to #49: you added the feature to save a binary response as file.

The "content-disposition" header in my use case is not parsed correctly, it does not seem to handle the case that the header has filenames in different encodings.
This is the header value:
attachment; filename=annacerrato_vbb_ritratti-02056.jpg; filename*=UTF-8''annacerrato_vbb_ritratti-02056.jpg

It is not set by myself, but generated by .NET6 code. My service method returns a "Microsoft.AspNetCore.Mvc.FileStreamResult" result, where I set a property "FileName".

And this is the suggested filename in the "save as" dialog:
image

@WolfgangHG Should be fixed now. Please check.

@flawiddsouza I wanted to test if with https://restfox.dev/, but every request just shows an error "Request failed". Even a request to "https://www.google.com" does not work (which works with the desktop client of Restfox). Is restfox.dev down?

@WolfgangHG restfox.dev does not run a server. All requests are made through your browser. Due to cors restrictions, all non cors enabled urls will fail. You should be seeing this error:
image
A chrome extension or a firefox extension is required to bypass cors restrictions on the browser if you want to test urls like google.com. See: Chrome | Firefox

Sorry, my error, with the extension it works, and your filename fix also works.

In comment #49 (comment) you wrote that I could also set a request header "Access-Control-Expose-Headers" instead of using the extension, so I tried this ;-).

In comment #49 (comment) you wrote that I could also set a request header "Access-Control-Expose-Headers" instead of using the extension, so I tried this ;-).

You can do this but you also need to add the two main CORS headers along with that. These two:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *

But I don't recommend adding this just for Restfox.