summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/cf-h1-proxy.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-04-05 16:59:16 (GMT)
committerBrad King <brad.king@kitware.com>2024-04-05 16:59:16 (GMT)
commit7fef14d8e0d9bb644a25fd3e3c5548d21724d03a (patch)
treeaa3d686c770b0cf7db4c9c698df7b13813e17ee9 /Utilities/cmcurl/lib/cf-h1-proxy.c
parent7ceb6e6c0b07af42ff990657b2ae0e8ac94fba5e (diff)
parente17d8d0c3b8f820bd108b8d66ace3692c81bbf42 (diff)
downloadCMake-7fef14d8e0d9bb644a25fd3e3c5548d21724d03a.zip
CMake-7fef14d8e0d9bb644a25fd3e3c5548d21724d03a.tar.gz
CMake-7fef14d8e0d9bb644a25fd3e3c5548d21724d03a.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2024-03-27 (de7b3e89)
Diffstat (limited to 'Utilities/cmcurl/lib/cf-h1-proxy.c')
-rw-r--r--Utilities/cmcurl/lib/cf-h1-proxy.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/Utilities/cmcurl/lib/cf-h1-proxy.c b/Utilities/cmcurl/lib/cf-h1-proxy.c
index 167e531..ed6322c 100644
--- a/Utilities/cmcurl/lib/cf-h1-proxy.c
+++ b/Utilities/cmcurl/lib/cf-h1-proxy.c
@@ -114,18 +114,12 @@ static CURLcode tunnel_init(struct Curl_cfilter *cf,
struct h1_tunnel_state **pts)
{
struct h1_tunnel_state *ts;
- CURLcode result;
if(cf->conn->handler->flags & PROTOPT_NOTCPPROXY) {
failf(data, "%s cannot be done over CONNECT", cf->conn->handler->scheme);
return CURLE_UNSUPPORTED_PROTOCOL;
}
- /* we might need the upload buffer for streaming a partial request */
- result = Curl_get_upload_buffer(data);
- if(result)
- return result;
-
ts = calloc(1, sizeof(*ts));
if(!ts)
return CURLE_OUT_OF_MEMORY;
@@ -212,6 +206,11 @@ static void tunnel_free(struct Curl_cfilter *cf,
}
}
+static bool tunnel_want_send(struct h1_tunnel_state *ts)
+{
+ return (ts->tunnel_state == H1_TUNNEL_CONNECT);
+}
+
#ifndef USE_HYPER
static CURLcode start_CONNECT(struct Curl_cfilter *cf,
struct Curl_easy *data,
@@ -238,6 +237,8 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf,
http_minor = (cf->conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ? 0 : 1;
result = Curl_h1_req_write_head(req, http_minor, &ts->request_data);
+ if(!result)
+ result = Curl_creader_set_null(data);
out:
if(result)
@@ -366,7 +367,6 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
{
CURLcode result = CURLE_OK;
struct SingleRequest *k = &data->req;
- curl_socket_t tunnelsocket = Curl_conn_cf_get_socket(cf, data);
char *linep;
size_t line_len;
int error, writetype;
@@ -386,7 +386,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
/* Read one byte at a time to avoid a race condition. Wait at most one
second before looping to ensure continuous pgrsUpdates. */
- result = Curl_read(data, tunnelsocket, &byte, 1, &nread);
+ result = Curl_conn_recv(data, cf->sockindex, &byte, 1, &nread);
if(result == CURLE_AGAIN)
/* socket buffer drained, return */
return CURLE_OK;
@@ -593,7 +593,9 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf,
goto error;
}
/* tell Hyper how to read/write network data */
- hyper_io_set_userdata(io, data);
+ h->io_ctx.data = data;
+ h->io_ctx.sockindex = cf->sockindex;
+ hyper_io_set_userdata(io, &h->io_ctx);
hyper_io_set_read(io, Curl_hyper_recv);
hyper_io_set_write(io, Curl_hyper_send);
conn->sockfd = tunnelsocket;
@@ -749,6 +751,10 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf,
if(result)
goto error;
+ result = Curl_creader_set_null(data);
+ if(result)
+ goto error;
+
sendtask = hyper_clientconn_send(client, req);
if(!sendtask) {
failf(data, "hyper_clientconn_send");
@@ -832,9 +838,9 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
int didwhat;
(void)ts;
- *done = FALSE;
- result = Curl_hyper_stream(data, cf->conn, &didwhat, done,
+ result = Curl_hyper_stream(data, cf->conn, &didwhat,
CURL_CSELECT_IN | CURL_CSELECT_OUT);
+ *done = data->req.done;
if(result || !*done)
return result;
if(h->exec) {
@@ -918,6 +924,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf,
* If the other side indicated a connection close, or if someone
* else told us to close this connection, do so now.
*/
+ Curl_req_soft_reset(&data->req, data);
if(ts->close_connection || conn->bits.close) {
/* Close this filter and the sub-chain, re-connect the
* sub-chain and continue. Closing this filter will
@@ -1003,11 +1010,9 @@ out:
*done = (result == CURLE_OK) && tunnel_is_established(cf->ctx);
if(*done) {
cf->connected = TRUE;
- /* Restore `data->req` fields that may habe been touched */
- data->req.header = TRUE; /* assume header */
- data->req.bytecount = 0;
- data->req.ignorebody = FALSE;
- Curl_client_cleanup(data);
+ /* The real request will follow the CONNECT, reset request partially */
+ Curl_req_soft_reset(&data->req, data);
+ Curl_client_reset(data);
Curl_pgrsSetUploadCounter(data, 0);
Curl_pgrsSetDownloadCounter(data, 0);
@@ -1031,7 +1036,7 @@ static void cf_h1_proxy_adjust_pollset(struct Curl_cfilter *cf,
wait for the socket to become readable to be able to get the
response headers or if we're still sending the request, wait
for write. */
- if(ts->CONNECT.sending == HTTPSEND_REQUEST)
+ if(tunnel_want_send(ts))
Curl_pollset_set_out_only(data, ps, sock);
else
Curl_pollset_set_in_only(data, ps, sock);