Repository navigation
http protocol filters - #23385
Closed
icing wants to merge 2 commits into
Closed
http protocol filters#23385icing wants to merge 2 commits into
icing wants to merge 2 commits into
Conversation
icing
force-pushed
the
http-proto-filters
branch
from
October 21, 2026 14:03
da4e813 to
3db2d7e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
HTTP/3-only validation is lost, and RTSP connections can incorrectly receive HTTP/2 filters.
2 open issues
What changed in this PR
This PR moves protocol-specific filter installation into connection setup, so HTTP/2 filters are connected before the connection is considered ready.
Changes:
- Adds a protocol
setup_filterscallback and a corresponding SETUP phase. - Moves HTTP/2 filter selection from request handling and HTTPS-CONNECT into the HTTP callback.
- Updates protocol registrations and adds filter-chain HTTP-version queries.
| File | Description |
|---|---|
| lib/ws.c | Registers HTTP filter setup for WebSocket connections. |
| lib/vssh/libssh2.c | Adds null callbacks for SCP and SFTP. |
| lib/vssh/libssh.c | Adds null callbacks for SCP and SFTP. |
| lib/tftp.c | Adds a null filter-setup callback. |
| lib/telnet.c | Adds a null filter-setup callback. |
| lib/smtp.c | Adds a null filter-setup callback. |
| lib/rtsp.c | Registers HTTP filter setup for RTSP. |
| lib/protocol.h | Defines the protocol filter-setup callback. |
| lib/pop3.c | Adds a null filter-setup callback. |
| lib/openldap.c | Updates the OpenLDAP protocol registration. |
| lib/mqtt.c | Updates MQTT and secure MQTT registrations. |
| lib/ldap.c | Updates the LDAP protocol registration. |
| lib/imap.c | Adds a null filter-setup callback. |
| lib/http2.h | Updates filter-local HTTP/2 switching declarations. |
| lib/http2.c | Makes HTTP/2 insertion operate at a specified filter. |
| lib/http.h | Declares the HTTP filter-setup callback. |
| lib/http.c | Moves HTTP version selection into filter setup. |
| lib/gopher.c | Updates Gopher protocol registrations. |
| lib/ftp.c | Adds a null filter-setup callback. |
| lib/file.c | Adds a null filter-setup callback. |
| lib/dict.c | Adds a null filter-setup callback. |
| lib/cfilters.h | Declares filter-chain HTTP-version queries. |
| lib/cfilters.c | Implements filter-chain HTTP-version queries. |
| lib/cf-setup.c | Adds and connects protocol filters during setup. |
| lib/cf-https-connect.c | Removes HTTP/2 insertion from HTTPS-CONNECT. |
Review effort: Balanced
Add a protocol callback `setup_filter()` that lets protocol handlers install their own connection filters once the base connection has been brought up. cf-setup call this once the IP/TLS/PROXY filters have connected. http protocol filters Use the protocol handler's `setup_filters()` callback to check on new HTTP connections ALPN and version needs to see if additional filters like HTTP/2 need to be added. Removes the need to check this in cf-https-connect.c as cf-setup implicitly takes care of this now.
- RTSP: check and limit HTTP versions to negotiate - HTTP: resurrect setup_connection() callback
icing
force-pushed
the
http-proto-filters
branch
from
October 22, 2026 08:37
3db2d7e to
b12ce33
Compare
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.


protocol filters
new protocol callback
setup_filters(struct Curl_easy *data, struct Curl_cfilter *cf)that allows a protocol handler to add filters into a connection filter chain.The
SETUPfilter will call this once the TLS/Proxy/IP filters have connected. The protocol handler can then query the filter chain for properties like the negotiated ALPN and decide what to do. TheSETUPfilter will then connect any added filters before it becomes "connected" itself.If a connection involves several
SETUPfilters (like withHTTPS-CONNECT), the protocol'ssetup_filters()will be called once by eachSETUPfilter.http protocol filter
The HTTP protocol handler provides a
setup_filters()callback to inspect the negotiated ALPN and adds a HTTP/2 filter when required.This used to be checked in the HTTP protocol handler just before sending a request. This is no longer necessary. Also, the
HTTPS-CONNECTfilter no longer has to care about this.A Cleaner Design
Before this change, a HTTP/2 connection was "established" without the HTTP/2 filter in place. It was deemed "completely connected", but it was incomplete, e.g. not really talking HTTP/2. An undefined state. When querying such a connection for properties like ALPN and HTTP version, the answers would not be consistent.
Other Use Cases
There are several protocol handlers in curl that have a "protoconnect" phase, e.g. where properties
with the server are negotiated and authentication may happen or TLS being added. It might be "better" to perform this an a protocol specific connection filter.