Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "CompressedStaticFileResult" #40

Open
judilsteve opened this issue Nov 24, 2022 · 4 comments
Open

Feature request: "CompressedStaticFileResult" #40

judilsteve opened this issue Nov 24, 2022 · 4 comments

Comments

@judilsteve
Copy link

judilsteve commented Nov 24, 2022

It would be fantastic to be able to call something like return CompressedStaticFileResult("some/file.html"); from a webapi controller method or return Results.CompressedStaticFile("some/file.html"); from a minimal API endpoint to leverage the conditional request and compressed file serving logic in custom endpoints. This would allow things like serving a 401/403 page with the appropriate status code.

I might be able to have a crack at this myself, I think it would look very similar to the CompressedStaticFileMiddleware class, except it would implement IActionResult and defer to PhysicalFileResult instead of StaticFileMiddleware. Would you consider accepting a PR?

@AnderssonPeter
Copy link
Owner

AnderssonPeter commented Nov 24, 2022

I would be more than happy to look at any pull request you send my way, but I can't promise if I will accept it or not, it all depends on the quality.
If I don't accept I will give you some hints on what to do to get it accepted.

I'm not 100% sure but I think you would need to have some sort of service for this as you would have a hard time accessing configuration of CompressedStaticFiles in a static method or class?

@AnderssonPeter
Copy link
Owner

Just a idea, haven't tried but what happens if you redirect instead? It might cause a extra roundtrip but should just work?

@judilsteve
Copy link
Author

judilsteve commented Nov 27, 2022

Ideally for my use case I'd like to do it within the request so that the user will see the URL of the page causing the error in their address bar, instead of some generic path like /403.html (which would be incongruently served with a 2xx response code). I suppose that option means giving up conditional request ability though (you can't respond to the same request with both 304 not modified and 403 forbidden at the same time).

I'll try drafting a PR when I can, but I work full time as a software dev so working on personal/OSS projects can often feel like working through the weekend.

@AnderssonPeter
Copy link
Owner

I totally understand both your work time and not wanting a redirect, no rush from me if you manage to get time it's fine, if not it's also fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants