]> git.kaiwu.me - haproxy.git/commitdiff
DEV: sse-latency: add a parameter after the content-type
authorWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 09:02:53 +0000 (10:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 09:02:53 +0000 (10:02 +0100)
As reported in GH issue #3574, we're currently using an exact match for
text/event-stream, and it fails to match when a parameter is appended.
Let's add one here to trigger this problem.

Without the parameter:
  === 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

With the parameter:
  === 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

Let's backport this to 3.4 since sse-latency was backported there, and to
any version containing a backport of 345aa2b73 ("DEV: sse-latency: add a
latency measuring tool for SSE response streams")

dev/sse-latency/sse-latency.c

index 9e760a280976ba2d91bfa0eb25fca0758551ae0e..cfa13eb877eb8b0c01145ce8d2460f5a04ee8202 100644 (file)
@@ -817,7 +817,7 @@ static int server_process_request(struct conn *c)
        /* response head + role chunk */
        hl = snprintf(head, sizeof(head),
                      "HTTP/1.1 200 OK\r\n"
-                     "Content-Type: text/event-stream\r\n"
+                     "Content-Type: text/event-stream; charset=utf-8\r\n"
                      "Cache-Control: no-cache\r\n"
                      "Connection: close\r\n"
                      "X-Accel-Buffering: no\r\n"