Repository navigation
Conversation
jhen0409
force-pushed
the
jhen/server-zlib
branch
from
August 31, 2026 03:26
a1f0fb6 to
34e967b
Compare
jhen0409
force-pushed
the
jhen/server-zlib
branch
from
September 11, 2026 05:52
34e967b to
2900d36
Compare
jhen0409
force-pushed
the
jhen/server-zlib
branch
from
September 12, 2026 12:40
2900d36 to
4e09b46
Compare
Member
Author
|
Rebased master, now it's ready for review. Also, I found it cannot set quality param for brotli, so it's significantly increases response time by default, I think the benefits of brotli support to be minimal at the moment. |
jhen0409
marked this pull request as ready for review
September 12, 2026 13:00
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Ref #27357 (gzip only, no brotli).
This adds a
LLAMA_ZLIBCMake option (default ON, gracefully disabled when zlib is not found) that builds the vendored cpp-httplib withCPPHTTPLIB_ZLIB_SUPPORT. cpp-httplib already implements both directions:Content-Encoding: gzipare decompressed automatically (decompressed size capped byCPPHTTPLIB_PAYLOAD_MAX_LENGTH, 100MB).This helps us save a lot of traffic in long, multi-turn conversations or even multimodal message conversations on compression API requests.
Accept-Encodingnegotiation. SSE streaming is unaffected (text/event-streamis excluded by httplib).text/event-streamis excluded by httplib)The fix in cpp-httplib
Enabling zlib exposed a double-encoding bug in cpp-httplib: the web UI serves build-time-gzipped assets with
Content-Encoding: gzipset by the handler, and httplib compresses them a second time (Safari renders raw gzip bytes). The patch skips compression when the handler already setContent-Encoding, deciding the coding once so headers and body agree.I'm submitted this patch upstream (PR: yhirose/cpp-httplib#2575, merged) and will keep this PR as a draft until
the upstream author agrees with the approachthe cpp-httplib released new version.Additional information
Validation:
/v1/chat/completions(text + image): same 200 and identicalprompt_tokensas the uncompressed request; the gzip request even hits the prompt cache populated by the plain one, confirming the decompressed bytes are byte-identical.Content-Encodingheader, single gzip layer);Accept-Encoding: gzipon/propsreturns a compressed response; SSE streaming unaffected.Possible follow-ups: compressing request bodies from the web UI, brotli.
Requirements