-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
ContentEncodingMiddleware to decompress incoming requests #14
Comments
I would like to see a implementation that does not have to unroll the entity stream into memory. Can this be implemented using a stream filter like here: https://github.com/guzzle/psr7/blob/master/src/InflateStream.php |
@bcremer I think that's the ultimate goal of the proposal - below the middleware example, @boesing indicates a @boesing — I like the idea of using a Strategy pattern here with gzip support by default. And per your remark about the I'd likely change your interface ProvideDecompressionStreamInterface
{
public function canDecompress(ServerRequestInterface $request): bool;
public function castToDecompressionStream(StreamInterface $body): StreamInterface;
} to make it more clear that it's recasting the body stream, instead of actually decompressing it. |
@weierophinney do you think, adding a constant called |
I think it would be a good addition - send a PR there, and then ping me with the URL. I have approval status on that repo, so if I approve it, we should be able to get it merged. |
Sadly, the |
Feature Request
Summary
I recently found out, that request payloads usually won't be compressed, as the client does not "challenge" possible encodings with the server.
After enforcing
Content-Encoding: gzip
on the client side (because we are requesting an internal API), I also found out that the Webserver (NGINX in our case) is not able to decompress incoming requests so that the application only gets the decompressed content. There is no such configuration without having annoying lua scripts within NGINX and thus, I've created a middleware to handle this.This middleware could be modified to handle multiple
Content-Encoding
header values (gzip
,br
, e.g.).Thus, I think we might want to have some kind of
ContentDecompressionInterface
like:Having
gzip
integrated with the middleware per-default would be okay for me.If anyone needs additional support, the interface can be used to implement all other types of encodings.
I am open to remove the dependency of the
BodyParamsMiddleware
as this would limit the requests to JSON/Form requests.Validation of the request methods with an exclude list might be a good idea aswell. Thats what
BodyParamsMiddleware
does aswell.Having these methods available as a constant would be something I'd like to see aswell. Maybe thats something we could contribute to
fig/http-message-util
@weierophinney?The text was updated successfully, but these errors were encountered: