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

Support compression for streaming REST endpoints that use google.api.HttpBody #96

Open
jhump opened this issue Oct 23, 2023 · 0 comments

Comments

@jhump
Copy link
Member

jhump commented Oct 23, 2023

Currently, requests received by the RPC handler will usually be compressed if the client compressed them, and responses sent to clients will usually be compressed if the RPC handler chose to compress them. If a message needs to be transcoded (e.g. re-serialized from protobuf to JSON), then it will be transparently re-compressed if the original form was compressed. However this is not the case for streaming REST endpoints, that use google.api.HttpBody messages to stream the body in chunks.

The current condition is largely due to the fact that all other streaming endpoints use per-message compression, not whole-body compression. To correct this, an exception is needed for the transcoder to use whole-body compression.

This will be more complicated to implement for compressed, streamed requests: re-compressing the entire stream, instead of just individual chunks/messages, will require the use of an io.Pipe and a dedicated goroutine to adapt a compressor, which implements io.Writer, to the request body, which must implement io.Reader. Supporting compressed responses, on the other hand, is simpler since both the compressor and the response body (in the form of http.ResponseWriter) both implement io.Writer.

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

1 participant