Skip to content

fix: never select chunked framing for an HTTP/3 request (stream writer) - #641

Merged
viniciussanchez merged 1 commit into
HashLoad:masterfrom
freitasjca:fix/streamwriter-h3-chunked
Dec 3, 2026
Merged

viniciussanchez merged 1 commit into
HashLoad:masterfrom
freitasjca:fix/streamwriter-h3-chunked

Conversation

@freitasjca

Copy link
Copy Markdown
Contributor

fix: never select chunked framing for an HTTP/3 request (stream writer)

Summary

THorseStreamWriterBase.Create in src/Horse.Response.pas picks chunked
transfer-coding for every protocol version except HTTP/2:

FUseChunked := (not SameText(LProtocol, 'HTTP/2')) and
               (not SameText(LContentType, 'text/event-stream'));

A provider whose RawWebRequest.ProtocolVersion reports HTTP/3 would
therefore get Transfer-Encoding: chunked on every streamed response. HTTP/3
frames the body itself and forbids Transfer-Encoding entirely (RFC 9114
§4.2), exactly as HTTP/2 does (RFC 9113 §8.2.2). This change excludes HTTP/3
the same way HTTP/2 is excluded, and nothing else:

FUseChunked := (not SameText(LProtocol, 'HTTP/2')) and
               (not SameText(LProtocol, 'HTTP/3')) and
               (not SameText(LContentType, 'text/event-stream'));

Why now

No Horse provider speaks HTTP/3 today. The transport-neutral core is the
reason to fix it ahead of one: THorseRequest already treats the WebSocket
upgrade signal as protocol-agnostic ("HTTP/3 uses the same extended-CONNECT
mechanism", Horse.Request.pas), and this is the one remaining place in core
where a protocol is named rather than a property of it. The change is one
and clause plus a comment; behaviour for every existing provider (HTTP/1.1
and HTTP/2) is unchanged.

Tests

No existing test exercises THorseStreamWriterBase by protocol version, and
no provider can produce HTTP/3 yet, so this PR carries no new test. The
existing streaming tests (Indy, HTTP.sys, IOCP, epoll, and the hybrid
providers' test 47) cover the unchanged HTTP/1.1 and HTTP/2 branches.

@viniciussanchez
viniciussanchez merged commit 16a7af2 into HashLoad:master Dec 3, 2026
2 checks passed
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