lib: separate scheme info from protocol implementation#20351
lib: separate scheme info from protocol implementation#20351
Conversation
9dc3b82 to
b488dee
Compare
|
Sounds like a good idea. |
b509f8e to
d35e447
Compare
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. In a next step this should allow the URL API to always work with all known protocols. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. Closes #20351
1b51506 to
120dbea
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the cURL library's protocol handling architecture by splitting the Curl_handler struct into two separate structs: Curl_scheme (containing scheme metadata) and Curl_protocol (containing protocol implementation function pointers). This separation allows builds to know about all schemes even when specific protocol implementations are disabled, and enables multiple schemes (like HTTP/HTTPS or WS/WSS) to share the same protocol implementation.
Changes:
- Split
Curl_handlerintoCurl_schemeandCurl_protocolstructs inurldata.h - Updated all protocol files to define separate scheme and protocol structs
- Changed references from
conn->handlertoconn->schemeandhandler->fieldtoscheme->fieldorscheme->run->fieldthroughout the codebase - Simplified
scripts/schemetable.cby removing conditional compilation from the scheme table - Fixed header guards in vssh files
Reviewed changes
Copilot reviewed 59 out of 59 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/urldata.h | Defines new Curl_protocol and Curl_scheme structs, replacing Curl_handler |
| lib/url.c | Updates scheme lookup and connection handling to use new structs |
| lib/multi.c | Updates protocol handler function calls to use conn->scheme->run->* |
| lib/transfer.c | Updates protocol checks to use conn->scheme->protocol |
| lib/ws.c | Splits WebSocket handler into protocol and scheme structs |
| lib/http.c | Splits HTTP/HTTPS handlers, sharing Curl_protocol_http implementation |
| lib/ftp.c | Splits FTP/FTPS handlers, sharing Curl_protocol_ftp implementation |
| lib/smtp.c, pop3.c, imap.c | Email protocols split handlers, share protocol implementations |
| lib/ldap.c, openldap.c | LDAP protocol split across files with shared implementation |
| lib/vssh/* | SSH protocols updated with scheme/protocol split and header guard fixes |
| scripts/schemetable.c | Simplified scheme table generation without conditional compilation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
augment review |
🤖 Augment PR SummarySummary: This PR refactors libcurl’s protocol metadata so URL schemes can be known independently of whether the corresponding protocol implementation is compiled in. Changes:
Technical Notes: This lays groundwork for always recognizing all known schemes (even when implementations are disabled) and for sharing a single protocol implementation across multiple schemes (e.g., TLS/non-TLS variants). 🤖 Was this summary useful? React with 👍 or 👎 |
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. The URL API now always work with all known protocols. Closes #20351
7d12094 to
57b0123
Compare
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. The URL API now always work with all known protocols. test1560: run without requiring all the protocols Closes #20351
3c78c52 to
0026f1f
Compare
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. The URL API now always work with all known protocols. test1560: run without requiring all the protocols Closes #20351
It was a little more complicated than that...
0026f1f to
8c4aa33
Compare
libcurl 8.19.0 supports all URL schemes even when the protocol itself is disabled. Refs: curl/curl@8edc033 curl/curl#20351
```
curl/lib/rtsp.c:1073:26: error: no previous extern declaration for non-static variable 'Curl_scheme_rtsp' [-Werror,-Wmissing-variable-declarations]
1073 | const struct Curl_scheme Curl_scheme_rtsp = {
| ^
curl/lib/rtsp.c:1073:7: note: declare 'static' if the variable is not intended to be used outside of this translation unit
1073 | const struct Curl_scheme Curl_scheme_rtsp = {
| ^
```
Follow-up to 8edc033 curl#20351
```
lib/rtsp.c:1073:26: error: no previous extern declaration for non-static variable 'Curl_scheme_rtsp' [-Werror,-Wmissing-variable-declarations]
1073 | const struct Curl_scheme Curl_scheme_rtsp = {
| ^
lib/rtsp.c:1073:7: note: declare 'static' if the variable is not intended to be used outside of this translation unit
1073 | const struct Curl_scheme Curl_scheme_rtsp = {
| ^
```
Ref: https://github.com/curl/trurl/actions/runs/21157411659/job/60844860592?pr=425#step:3:3036
Follow-up to 8edc033 #20351
Closes #20365
libcurl 8.19.0 supports all URL schemes even when the protocol itself is disabled. Refs: curl/curl@8edc033 curl/curl#20351
Follow-up to 8edc033 curl#20351
This allows builds know about all schemes - but only have the protocol
implementations for those actually built-in.
It further allows multiple protocols to reuse the same protocol setup
and functions for both TLS and non-TLS implementations instead of
needing two (or more) structs.
The scheme information is now in 'struct Curl_scheme' and all the
function pointers for each scheme/protocol implementation are in struct
Curl_protocol.
The URL API now always work with all known protocols.