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

Decompression service decompress the request #276

Closed
Antti opened this issue Jun 27, 2022 · 6 comments
Closed

Decompression service decompress the request #276

Antti opened this issue Jun 27, 2022 · 6 comments
Labels
A-new-middleware Area: new middleware proposals C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@Antti
Copy link

Antti commented Jun 27, 2022

Feature Request

Add request decompression to the Decompression service. This would be used on the server-side to decompress client requests, in addition to the existing logic to decompress server responses.

Motivation

In our company, we are using Axum for our internal APIs and posting large JSON payloads. While we are planning to move to some more space-efficient formats, it would help a lot if we could compress the client request body using standard compression methods (gzip, deflate, br).

Proposal

Implement decompression for the requests based on the Content-Encoding header

Alternatives

Possibly create a separate service/layer for this?

@davidpdrsn
Copy link
Member

This has been requested before but the question has always been how to handle unsupported encodings.

About content-encoding the spec says

An origin server MAY respond with a status code of 415 (Unsupported Media Type) if a representation in the request message has a content coding that is not acceptable.

So I suppose we could do just do that.

Most of machinery is already there so this is probably not hard.

@davidpdrsn davidpdrsn added A-new-middleware Area: new middleware proposals C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Jun 27, 2022
@Antti
Copy link
Author

Antti commented Jun 27, 2022

@davidpdrsn I did manage to make it work for us with the following changes (although 1 example and tests do not compile with some type errors).
fetlife@f284328

It doesn't handle the unsupported content-encoding though.

@davidpdrsn
Copy link
Member

I think we have to add a new middleware. Changing the trait bounds like that is a breaking change.

@wanderinglethe
Copy link
Contributor

wanderinglethe commented Jul 6, 2022

I have created a branch with decompression middleware for request bodies.

It still needs documentation and refactoring/naming to coexist with the other Decompression middleware.

--

I refactored the decompression module, but I am not sure if this is the correct way. I have renamed Decompression to ResponseDecompression and then exported it as Decompression. But it looks like rust doc does not rename everything.

And to return Unsupported Media Type, would I need a separate ResponseFuture?

@leio
Copy link

leio commented Mar 21, 2023

Given that #282 is merged and released, I think this issue can be closed as well?

@davidpdrsn
Copy link
Member

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-new-middleware Area: new middleware proposals C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

4 participants