Skip to content

add gzip compression/decompression support#332

Merged
Guest0x0 merged 3 commits intomainfrom
gzip-compression
Apr 10, 2026
Merged

add gzip compression/decompression support#332
Guest0x0 merged 3 commits intomainfrom
gzip-compression

Conversation

@Guest0x0
Copy link
Copy Markdown
Collaborator

@Guest0x0 Guest0x0 commented Apr 9, 2026

This PR introduces gzip compression/decompression support for moonbitlang/async:

  • an internal package moonbitlang/async/internal/gzip_internal provides state-machine style, IO-independent gzip encoding/decoding support
  • a public package moonbitlang/async/gzip provides streaming gzip encoding/decoding support in the form of @io.Reader/@io.Writer transformer
  • @http.Client can now automatically utilize HTTP gzip compression. It works as follows:
    • if the user explicitly supplied Accept-Encoding, automatic decompression will be skipped, the user get raw, encoded traffic when reading the response, and must manually decode the traffic
    • if the user did not supply Accept-Encoding, @http.Client will set Accept-Encoding: gzip,identity as a default. In this case, if the Content-Encoding is gzip from the server response, the client will perform automatic decompression, so the user still get uncompressed result, as intended
      • note that when automatic decompression happens, the Content-Length field will no longer be visible to the user (even if it is present) to avoid confusion, because it stores length of compressed content

@Guest0x0 Guest0x0 force-pushed the gzip-compression branch 2 times, most recently from 61ff999 to bc7e46d Compare April 9, 2026 09:19
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 9, 2026

Coverage Report for CI Build 177

Coverage increased (+1.9%) to 78.405%

Details

  • Coverage increased (+1.9%) from the base build.
  • Patch coverage: 50 uncovered changes across 7 files (464 of 514 lines covered, 90.27%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/internal/gzip_internal/decoder.mbt 258 227 87.98%
src/http/parser.mbt 54 48 88.89%
src/internal/gzip_internal/encoder.mbt 99 94 94.95%
src/internal/gzip_internal/huffman.mbt 33 29 87.88%
src/internal/gzip_internal/metadata.mbt 20 18 90.0%
src/gzip/decoder.mbt 21 20 95.24%
src/gzip/encoder.mbt 15 14 93.33%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3825
Covered Lines: 2999
Line Coverage: 78.41%
Coverage Strength: 64785.94 hits per line

💛 - Coveralls

@Guest0x0 Guest0x0 merged commit 249b2e2 into main Apr 10, 2026
17 checks passed
@Guest0x0 Guest0x0 deleted the gzip-compression branch April 10, 2026 08:15
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

Successfully merging this pull request may close these issues.

2 participants