diff options
author | Brad King <brad.king@kitware.com> | 2023-08-01 17:58:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-08-01 17:58:24 (GMT) |
commit | 188c065e5a447e4c659426e0c27051928c8adb6e (patch) | |
tree | 91af173dfc4e42b50510e998778aa4886d68faeb /Utilities/cmcurl/lib/cf-h1-proxy.c | |
parent | 1345c21275574dd66f7adadc9123682488856ba1 (diff) | |
parent | e2ab2da70a2b390eb9067d45dfa47023b00c5cd7 (diff) | |
download | CMake-188c065e5a447e4c659426e0c27051928c8adb6e.zip CMake-188c065e5a447e4c659426e0c27051928c8adb6e.tar.gz CMake-188c065e5a447e4c659426e0c27051928c8adb6e.tar.bz2 |
Merge branch 'upstream-curl' into update-curl
* upstream-curl:
curl 2023-07-26 (50490c06)
Diffstat (limited to 'Utilities/cmcurl/lib/cf-h1-proxy.c')
-rw-r--r-- | Utilities/cmcurl/lib/cf-h1-proxy.c | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/Utilities/cmcurl/lib/cf-h1-proxy.c b/Utilities/cmcurl/lib/cf-h1-proxy.c index b42c4e6..c9b157c 100644 --- a/Utilities/cmcurl/lib/cf-h1-proxy.c +++ b/Utilities/cmcurl/lib/cf-h1-proxy.c @@ -54,16 +54,16 @@ typedef enum { - TUNNEL_INIT, /* init/default/no tunnel state */ - TUNNEL_CONNECT, /* CONNECT request is being send */ - TUNNEL_RECEIVE, /* CONNECT answer is being received */ - TUNNEL_RESPONSE, /* CONNECT response received completely */ - TUNNEL_ESTABLISHED, - TUNNEL_FAILED -} tunnel_state; + H1_TUNNEL_INIT, /* init/default/no tunnel state */ + H1_TUNNEL_CONNECT, /* CONNECT request is being send */ + H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */ + H1_TUNNEL_RESPONSE, /* CONNECT response received completely */ + H1_TUNNEL_ESTABLISHED, + H1_TUNNEL_FAILED +} h1_tunnel_state; /* struct for HTTP CONNECT tunneling */ -struct tunnel_state { +struct h1_tunnel_state { int sockindex; const char *hostname; int remote_port; @@ -78,23 +78,23 @@ struct tunnel_state { KEEPON_IGNORE } keepon; curl_off_t cl; /* size of content to read and ignore */ - tunnel_state tunnel_state; + h1_tunnel_state tunnel_state; BIT(chunked_encoding); BIT(close_connection); }; -static bool tunnel_is_established(struct tunnel_state *ts) +static bool tunnel_is_established(struct h1_tunnel_state *ts) { - return ts && (ts->tunnel_state == TUNNEL_ESTABLISHED); + return ts && (ts->tunnel_state == H1_TUNNEL_ESTABLISHED); } -static bool tunnel_is_failed(struct tunnel_state *ts) +static bool tunnel_is_failed(struct h1_tunnel_state *ts) { - return ts && (ts->tunnel_state == TUNNEL_FAILED); + return ts && (ts->tunnel_state == H1_TUNNEL_FAILED); } -static CURLcode tunnel_reinit(struct tunnel_state *ts, +static CURLcode tunnel_reinit(struct h1_tunnel_state *ts, struct connectdata *conn, struct Curl_easy *data) { @@ -102,7 +102,7 @@ static CURLcode tunnel_reinit(struct tunnel_state *ts, DEBUGASSERT(ts); Curl_dyn_reset(&ts->rcvbuf); Curl_dyn_reset(&ts->req); - ts->tunnel_state = TUNNEL_INIT; + ts->tunnel_state = H1_TUNNEL_INIT; ts->keepon = KEEPON_CONNECT; ts->cl = 0; ts->close_connection = FALSE; @@ -124,12 +124,12 @@ static CURLcode tunnel_reinit(struct tunnel_state *ts, return CURLE_OK; } -static CURLcode tunnel_init(struct tunnel_state **pts, +static CURLcode tunnel_init(struct h1_tunnel_state **pts, struct Curl_easy *data, struct connectdata *conn, int sockindex) { - struct tunnel_state *ts; + struct h1_tunnel_state *ts; CURLcode result; if(conn->handler->flags & PROTOPT_NOTCPPROXY) { @@ -157,16 +157,16 @@ static CURLcode tunnel_init(struct tunnel_state **pts, return tunnel_reinit(ts, conn, data); } -static void tunnel_go_state(struct Curl_cfilter *cf, - struct tunnel_state *ts, - tunnel_state new_state, - struct Curl_easy *data) +static void h1_tunnel_go_state(struct Curl_cfilter *cf, + struct h1_tunnel_state *ts, + h1_tunnel_state new_state, + struct Curl_easy *data) { if(ts->tunnel_state == new_state) return; /* leaving this one */ switch(ts->tunnel_state) { - case TUNNEL_CONNECT: + case H1_TUNNEL_CONNECT: data->req.ignorebody = FALSE; break; default: @@ -174,36 +174,36 @@ static void tunnel_go_state(struct Curl_cfilter *cf, } /* entering this one */ switch(new_state) { - case TUNNEL_INIT: + case H1_TUNNEL_INIT: DEBUGF(LOG_CF(data, cf, "new tunnel state 'init'")); tunnel_reinit(ts, cf->conn, data); break; - case TUNNEL_CONNECT: + case H1_TUNNEL_CONNECT: DEBUGF(LOG_CF(data, cf, "new tunnel state 'connect'")); - ts->tunnel_state = TUNNEL_CONNECT; + ts->tunnel_state = H1_TUNNEL_CONNECT; ts->keepon = KEEPON_CONNECT; Curl_dyn_reset(&ts->rcvbuf); break; - case TUNNEL_RECEIVE: + case H1_TUNNEL_RECEIVE: DEBUGF(LOG_CF(data, cf, "new tunnel state 'receive'")); - ts->tunnel_state = TUNNEL_RECEIVE; + ts->tunnel_state = H1_TUNNEL_RECEIVE; break; - case TUNNEL_RESPONSE: + case H1_TUNNEL_RESPONSE: DEBUGF(LOG_CF(data, cf, "new tunnel state 'response'")); - ts->tunnel_state = TUNNEL_RESPONSE; + ts->tunnel_state = H1_TUNNEL_RESPONSE; break; - case TUNNEL_ESTABLISHED: + case H1_TUNNEL_ESTABLISHED: DEBUGF(LOG_CF(data, cf, "new tunnel state 'established'")); infof(data, "CONNECT phase completed"); data->state.authproxy.done = TRUE; data->state.authproxy.multipass = FALSE; /* FALLTHROUGH */ - case TUNNEL_FAILED: - if(new_state == TUNNEL_FAILED) + case H1_TUNNEL_FAILED: + if(new_state == H1_TUNNEL_FAILED) DEBUGF(LOG_CF(data, cf, "new tunnel state 'failed'")); ts->tunnel_state = new_state; Curl_dyn_reset(&ts->rcvbuf); @@ -225,9 +225,9 @@ static void tunnel_go_state(struct Curl_cfilter *cf, static void tunnel_free(struct Curl_cfilter *cf, struct Curl_easy *data) { - struct tunnel_state *ts = cf->ctx; + struct h1_tunnel_state *ts = cf->ctx; if(ts) { - tunnel_go_state(cf, ts, TUNNEL_FAILED, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); Curl_dyn_free(&ts->rcvbuf); Curl_dyn_free(&ts->req); free(ts); @@ -270,7 +270,7 @@ static CURLcode CONNECT_host(struct Curl_easy *data, #ifndef USE_HYPER static CURLcode start_CONNECT(struct Curl_cfilter *cf, struct Curl_easy *data, - struct tunnel_state *ts) + struct h1_tunnel_state *ts) { struct connectdata *conn = cf->conn; char *hostheader = NULL; @@ -351,7 +351,7 @@ out: static CURLcode send_CONNECT(struct Curl_easy *data, struct connectdata *conn, - struct tunnel_state *ts, + struct h1_tunnel_state *ts, bool *done) { struct SingleRequest *k = &data->req; @@ -399,7 +399,7 @@ out: static CURLcode on_resp_header(struct Curl_cfilter *cf, struct Curl_easy *data, - struct tunnel_state *ts, + struct h1_tunnel_state *ts, const char *header) { CURLcode result = CURLE_OK; @@ -475,7 +475,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, struct Curl_easy *data, - struct tunnel_state *ts, + struct h1_tunnel_state *ts, bool *done) { CURLcode result = CURLE_OK; @@ -671,7 +671,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, /* The Hyper version of CONNECT */ static CURLcode start_CONNECT(struct Curl_cfilter *cf, struct Curl_easy *data, - struct tunnel_state *ts) + struct h1_tunnel_state *ts) { struct connectdata *conn = cf->conn; struct hyptransfer *h = &data->hyp; @@ -882,7 +882,7 @@ error: static CURLcode send_CONNECT(struct Curl_easy *data, struct connectdata *conn, - struct tunnel_state *ts, + struct h1_tunnel_state *ts, bool *done) { struct hyptransfer *h = &data->hyp; @@ -919,7 +919,7 @@ error: static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, struct Curl_easy *data, - struct tunnel_state *ts, + struct h1_tunnel_state *ts, bool *done) { struct hyptransfer *h = &data->hyp; @@ -949,9 +949,9 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, #endif /* USE_HYPER */ -static CURLcode CONNECT(struct Curl_cfilter *cf, - struct Curl_easy *data, - struct tunnel_state *ts) +static CURLcode H1_CONNECT(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h1_tunnel_state *ts) { struct connectdata *conn = cf->conn; CURLcode result; @@ -973,25 +973,25 @@ static CURLcode CONNECT(struct Curl_cfilter *cf, } switch(ts->tunnel_state) { - case TUNNEL_INIT: + case H1_TUNNEL_INIT: /* Prepare the CONNECT request and make a first attempt to send. */ DEBUGF(LOG_CF(data, cf, "CONNECT start")); result = start_CONNECT(cf, data, ts); if(result) goto out; - tunnel_go_state(cf, ts, TUNNEL_CONNECT, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_CONNECT, data); /* FALLTHROUGH */ - case TUNNEL_CONNECT: + case H1_TUNNEL_CONNECT: /* see that the request is completely sent */ DEBUGF(LOG_CF(data, cf, "CONNECT send")); result = send_CONNECT(data, cf->conn, ts, &done); if(result || !done) goto out; - tunnel_go_state(cf, ts, TUNNEL_RECEIVE, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_RECEIVE, data); /* FALLTHROUGH */ - case TUNNEL_RECEIVE: + case H1_TUNNEL_RECEIVE: /* read what is there */ DEBUGF(LOG_CF(data, cf, "CONNECT receive")); result = recv_CONNECT_resp(cf, data, ts, &done); @@ -1003,10 +1003,10 @@ static CURLcode CONNECT(struct Curl_cfilter *cf, if(result || !done) goto out; /* got it */ - tunnel_go_state(cf, ts, TUNNEL_RESPONSE, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_RESPONSE, data); /* FALLTHROUGH */ - case TUNNEL_RESPONSE: + case H1_TUNNEL_RESPONSE: DEBUGF(LOG_CF(data, cf, "CONNECT response")); if(data->req.newurl) { /* not the "final" response, we need to do a follow up request. @@ -1028,7 +1028,7 @@ static CURLcode CONNECT(struct Curl_cfilter *cf, } else { /* staying on this connection, reset state */ - tunnel_go_state(cf, ts, TUNNEL_INIT, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_INIT, data); } } break; @@ -1039,25 +1039,25 @@ static CURLcode CONNECT(struct Curl_cfilter *cf, } while(data->req.newurl); - DEBUGASSERT(ts->tunnel_state == TUNNEL_RESPONSE); + DEBUGASSERT(ts->tunnel_state == H1_TUNNEL_RESPONSE); if(data->info.httpproxycode/100 != 2) { /* a non-2xx response and we have no next url to try. */ Curl_safefree(data->req.newurl); /* failure, close this connection to avoid re-use */ streamclose(conn, "proxy CONNECT failure"); - tunnel_go_state(cf, ts, TUNNEL_FAILED, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); failf(data, "CONNECT tunnel failed, response %d", data->req.httpcode); return CURLE_RECV_ERROR; } /* 2xx response, SUCCESS! */ - tunnel_go_state(cf, ts, TUNNEL_ESTABLISHED, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_ESTABLISHED, data); infof(data, "CONNECT tunnel established, response %d", data->info.httpproxycode); result = CURLE_OK; out: if(result) - tunnel_go_state(cf, ts, TUNNEL_FAILED, data); + h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); return result; } @@ -1066,7 +1066,7 @@ static CURLcode cf_h1_proxy_connect(struct Curl_cfilter *cf, bool blocking, bool *done) { CURLcode result; - struct tunnel_state *ts = cf->ctx; + struct h1_tunnel_state *ts = cf->ctx; if(cf->connected) { *done = TRUE; @@ -1074,7 +1074,7 @@ static CURLcode cf_h1_proxy_connect(struct Curl_cfilter *cf, } DEBUGF(LOG_CF(data, cf, "connect")); - result = cf->next->cft->connect(cf->next, data, blocking, done); + result = cf->next->cft->do_connect(cf->next, data, blocking, done); if(result || !*done) return result; @@ -1089,7 +1089,7 @@ static CURLcode cf_h1_proxy_connect(struct Curl_cfilter *cf, /* TODO: can we do blocking? */ /* We want "seamless" operations through HTTP proxy tunnel */ - result = CONNECT(cf, data, ts); + result = H1_CONNECT(cf, data, ts); if(result) goto out; Curl_safefree(data->state.aptr.proxyuserpwd); @@ -1107,7 +1107,7 @@ static int cf_h1_proxy_get_select_socks(struct Curl_cfilter *cf, struct Curl_easy *data, curl_socket_t *socks) { - struct tunnel_state *ts = cf->ctx; + struct h1_tunnel_state *ts = cf->ctx; int fds; fds = cf->next->cft->get_select_socks(cf->next, data, socks); @@ -1143,10 +1143,10 @@ static void cf_h1_proxy_close(struct Curl_cfilter *cf, DEBUGF(LOG_CF(data, cf, "close")); cf->connected = FALSE; if(cf->ctx) { - tunnel_go_state(cf, cf->ctx, TUNNEL_INIT, data); + h1_tunnel_go_state(cf, cf->ctx, H1_TUNNEL_INIT, data); } if(cf->next) - cf->next->cft->close(cf->next, data); + cf->next->cft->do_close(cf->next, data); } |