Skip to content

make io.Reader compressible in responses#4401

Draft
gudvinr wants to merge 1 commit into
miniflux:mainfrom
gudvinr:feature/response_any_body
Draft

make io.Reader compressible in responses#4401
gudvinr wants to merge 1 commit into
miniflux:mainfrom
gudvinr:feature/response_any_body

Conversation

@gudvinr

@gudvinr gudvinr commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

As you can pipe data from reader to write through io.Copy it is possible to compress any reader quite easily.

And, since []byte and string can be converted to io.Reader too the whole implementation looks tidier. At least in my eyes.

Chechking for Size methods is done because bytes.Reader and strings.Reader do provide these. If io.Reader doesn't have Size method and encoding allows that it'd be compressed unconditionally.

406 Not Acceptable will be returned as per MDN. Only if uncompressed encoding explicitly disabled (e.g. identity;q=0) and we don't support any compression that client wants. That should be quite rare occasion I suppose.

This should be merged after #4370.


Have you followed these guidelines?

Comment thread internal/http/response/builder.go Outdated
Comment thread internal/http/response/builder.go
Comment thread internal/http/response/encoding.go Outdated
@gudvinr gudvinr force-pushed the feature/response_any_body branch 3 times, most recently from 3ddf793 to 48badbe Compare June 19, 2026 15:44
No reason to skip io.Reader as all compressors happily work with readers.

As a bonus, every input is now io.Reader internally so no more different code paths
@gudvinr gudvinr force-pushed the feature/response_any_body branch from 48badbe to 688334b Compare July 4, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants