]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: http-ana: also match text/event-stream with trailing parameters
authorWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 09:06:42 +0000 (10:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 09:09:24 +0000 (10:09 +0100)
Commit 5ff6ff1b7 ("MINOR: http-ana: automatically enable http-no-delay
for streaming events (SSE)") added detection for SSE, but as reported
in GH issue #3574, it fails when there's a parameter after the content
type because we're using an exact match. Let's instead use istmatchi()
that will check the beginning of the string (which is sufficient here).

Before:
  === gateway overhead (gateway minus loopback; negative = loopback noise) ===
  emit->recv (1st token)   mean +214.379ms  p50 +214.379ms  p95 +214.379ms  p99 +214.379ms
  emit->recv (tokens)      mean +303.484ms  p50 +307.784ms  p95 +405.797ms  p99 +413.876ms
  TTFT (client)            mean +214.775ms  p50 +214.775ms  p95 +214.775ms  p99 +214.775ms
  inter-token (client)     mean -0.026ms  p50 -1.069ms  p95 -1.260ms  p99 -1.271ms

After:
  === gateway overhead (gateway minus loopback; negative = loopback noise) ===
  emit->recv (1st token)   mean +0.046ms  p50 +0.046ms  p95 +0.046ms  p99 +0.046ms
  emit->recv (tokens)      mean +0.214ms  p50 +0.234ms  p95 +0.305ms  p99 +0.322ms
  TTFT (client)            mean +0.493ms  p50 +0.493ms  p95 +0.493ms  p99 +0.493ms
  inter-token (client)     mean -0.001ms  p50 +0.230ms  p95 +0.283ms  p99 +0.299ms

This should be backported to 3.4 since the commit above is already there.
Thanks to @glenn-jocher for reporting and diagnosinc this limitation.

src/http_ana.c

index 130fa5974db094addcf13839a6ecfe84f83f81fa..01a59753bcc0554ace25baa5255c581cd27e869c 100644 (file)
@@ -1677,7 +1677,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                struct http_hdr_ctx ctx = { .blk = NULL };
 
                if (http_find_header(htx, ist("content-type"), &ctx, 0) &&
-                   isteqi(ctx.value, ist("text/event-stream"))) {
+                   istmatchi(ctx.value, ist("text/event-stream"))) {
                        s->scf->flags |= SC_FL_SND_NEVERWAIT;
                        s->scb->flags |= SC_FL_SND_NEVERWAIT;
                }