Skip to content

Add HTTP gzip/zstd compression and WebSocket permessage-deflate support#819

Open
ProjectSky wants to merge 3 commits intoithewei:masterfrom
ProjectSky:http-ws-compression
Open

Add HTTP gzip/zstd compression and WebSocket permessage-deflate support#819
ProjectSky wants to merge 3 commits intoithewei:masterfrom
ProjectSky:http-ws-compression

Conversation

@ProjectSky
Copy link

  • Add configurable HTTP gzip/zstd compression support
  • Add WebSocket permessage-deflate negotiation & message handling
  • Add WITH_ZLIB/WITH_ZSTD build options and update build/docs/CI
  • Add compression-related unit tests

@ithewei ithewei requested a review from Copilot March 19, 2026 03:20
@ithewei ithewei marked this pull request as ready for review March 19, 2026 03:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class HTTP response/request compression (gzip/zstd) and WebSocket permessage-deflate support, including negotiation, framing (RSV1), and extensive unit test coverage. It also introduces new build toggles (WITH_ZLIB/WITH_ZSTD) and wires them into the project’s build + CI tooling.

Changes:

  • Add HTTP compression utilities (Accept-Encoding selection, request/response compression, streaming decompression) and integrate into HTTP server/client paths.
  • Add WebSocket permessage-deflate negotiation plus RSV1-aware frame building, compression on send, and decompression in the WebSocket parser.
  • Add new HTTP/WebSocket compression unit tests and update CMake/Make/Bazel/CI/build docs to support zlib/zstd options.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
unittest/websocket_compression_test.cpp Adds negotiation + parser safety tests and an end-to-end compressed WebSocket echo test.
unittest/http_compression_test.cpp Adds comprehensive HTTP compression/decompression behavior tests (client/server, headers, edge cases).
unittest/CMakeLists.txt Builds the new compression test binaries under HTTP-enabled configurations.
scripts/unittest.sh Runs new compression tests when the binaries are present.
http/wsdef.h / http/wsdef.c Adds ws_build_frame_ex to support RSV1 when building frames.
http/websocket_parser.h / http/websocket_parser.c Tracks RSV bits during parse and supports RSV1 emission during build.
http/server/WebSocketServer.h Adds server-side WebSocket compression options to WebSocketService.
http/server/HttpService.h Adds server-wide HttpCompressionOptions defaults on HttpService.
http/server/HttpResponseWriter.h / .cpp Threads request/service context into writer and applies compression before sending headers/body.
http/server/HttpHandler.h / .cpp Implements request decompression, response compression, static-file ETag variance by encoding, and WS extension negotiation.
http/http_compress.h / http/http_compress.cpp Introduces the shared compression implementation (HTTP + WS helpers, streaming decoder, deflater/inflater).
http/client/WebSocketClient.h / .cpp Adds permessage-deflate offer/confirm logic and config surface to the client.
http/client/HttpClient.h / .cpp Adds client compression configuration, request auto-compress, response auto-decode via adapter; adjusts redirect flow.
http/client/AsyncHttpClient.h / .cpp Adds response decoder adapter support and request auto-compress for async client.
http/WebSocketParser.h / .cpp Adds permessage-deflate decompression support and stricter frame validation (RSV/opcodes/control frames).
http/WebSocketChannel.h / .cpp Adds permessage-deflate compression on send and RSV1 marking on first frame.
http/HttpMessage.h / .cpp Adds compression options to messages plus Content-Encoding helpers and Accept-Encoding builder.
http/HttpCompression.h Defines public compression option structs and content-encoding enums.
configure / config.ini Adds configure/config toggles for WITH_ZLIB/WITH_ZSTD.
cmake/vars.cmake / CMakeLists.txt Adds headers and build options for zlib/zstd.
Makefile.vars / Makefile.in / Makefile Adds headers and link flags, and builds compression tests in make unittest.
BUILD.md Documents how to build with zlib/zstd enabled.
BUILD.bazel Adds zlib/zstd defines/linkopts and new compression cc_test targets.
.github/workflows/CI.yml Installs zlib/zstd deps and enables them in CI configure invocation.
base/herr.h Adds new error codes for unsupported encoding/compress/decompress failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ion check, and make compression tests work without zstd
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