conncontrol: reuse handling

Add protocol handler flag `PROTOPT_CONN_REUSE` to indicate that the
protocol allows reusing connections for other tranfers. Add that
to all handlers that support it.

Create connections with `conn->bits.close = FALSE` and remove all
the `connkeep()` calls in protocol handlers setup/connect implementations.
`PROTOPT_CONN_REUSE` assures that the default behaviour applies
at the end of a transfer without need to juggle the close bit.

`conn->bits.close` now serves as an additional indication that a
connection cannot be reused. Only protocol handles that allow
reuse need to set it to override the default behaviour.

Remove all `connclose()` and `connkeep()` calls from connection
filters. Filters should not modify connection flags. They are
supposed to run in eyeballing situations where a filter is just
one of many determining the outcome.

Fix http response header handling to only honour `Connection: close`
for HTTP/1.x versions.

Closes #19333
This commit is contained in:
Stefan Eissing 2025-11-03 13:12:50 +01:00 committed by Daniel Stenberg
parent a9e7a027ed
commit feea968512
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
21 changed files with 93 additions and 114 deletions

View file

@ -270,7 +270,8 @@ const struct Curl_handler Curl_handler_ftp = {
CURLPROTO_FTP, /* family */
PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD |
PROTOPT_NOURLQUERY | PROTOPT_PROXY_AS_HTTP |
PROTOPT_WILDCARD | PROTOPT_SSL_REUSE /* flags */
PROTOPT_WILDCARD | PROTOPT_SSL_REUSE |
PROTOPT_CONN_REUSE /* flags */
};
@ -302,7 +303,8 @@ const struct Curl_handler Curl_handler_ftps = {
CURLPROTO_FTPS, /* protocol */
CURLPROTO_FTP, /* family */
PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION |
PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD /* flags */
PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD |
PROTOPT_CONN_REUSE /* flags */
};
#endif
@ -3183,9 +3185,6 @@ static CURLcode ftp_connect(struct Curl_easy *data,
if(!ftpc)
return CURLE_FAILED_INIT;
pp = &ftpc->pp;
/* We always support persistent connections on ftp */
connkeep(conn, "FTP default");
PINGPONG_SETUP(pp, ftp_pp_statemachine, ftp_endofresp);
if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) {