]> git.kaiwu.me - haproxy.git/commit
MINOR: compression: pass COMP_CT_EVENT to the algorithms for server-sent events
authorWilly Tarreau <w@1wt.eu>
Sun, 15 Nov 2026 21:42:06 +0000 (22:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 08:20:00 +0000 (09:20 +0100)
commit4d0db5e7bf6758430a581ab0ef5d41ba4ce470b6
tree2ac65f0b4023ccbd8bad7eec2f0e97a117f25819
parent5ccaa1aa28cb74a5688b8a0c14737748ad6f548d
MINOR: compression: pass COMP_CT_EVENT to the algorithms for server-sent events

Server-sent events ("text/event-stream"), as emitted by AI and API
gateways, are made of small events that are flushed one at a time, each
of which repeats most of the previous one. Compressing them one at a time
without any history is useless, but an algorithm may handle them
differently if it knows about them.

select_compression_response_header() now sets the content type to the new
COMP_CT_EVENT when the Content-Type header starts with "text/event-stream".
Requests are left untouched: server-sent events only exist in responses,
and since an algorithm may need memory for this content type, clients
must not be able to force it. The algorithms don't make use of it yet and
treat it as COMP_CT_GENERIC.

This already improves the compression ratio for SSE to be below unity:

               bytes in    bytes out    ratio
      before:    227584       232303     102%
      after:     227584       199829      88%
include/haproxy/compression-t.h
src/flt_http_comp.c