diff options
author | dartraiden <wowemuh@gmail.com> | 2023-10-11 18:36:33 +0300 |
---|---|---|
committer | dartraiden <wowemuh@gmail.com> | 2023-10-11 18:38:34 +0300 |
commit | b7dfc6fda6f6b461f45a2ce457911bf128160208 (patch) | |
tree | 795d58d5d6d83c483022c3e14640f5999d0c0623 /libs/libcurl/src/cf-h2-proxy.c | |
parent | f40b2ce583f05b0756c4552f2e46535bea2c0c39 (diff) |
libcurl: update to 8.4.0
Diffstat (limited to 'libs/libcurl/src/cf-h2-proxy.c')
-rw-r--r-- | libs/libcurl/src/cf-h2-proxy.c | 79 |
1 files changed, 23 insertions, 56 deletions
diff --git a/libs/libcurl/src/cf-h2-proxy.c b/libs/libcurl/src/cf-h2-proxy.c index c18e1e0cf7..aab4f4661b 100644 --- a/libs/libcurl/src/cf-h2-proxy.c +++ b/libs/libcurl/src/cf-h2-proxy.c @@ -84,7 +84,8 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf, {
const char *hostname;
int port;
- bool ipv6_ip = cf->conn->bits.ipv6_ip;
+ bool ipv6_ip;
+ CURLcode result;
ts->state = H2_TUNNEL_INIT;
ts->stream_id = -1;
@@ -92,22 +93,9 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf, BUFQ_OPT_SOFT_LIMIT);
Curl_bufq_init(&ts->sendbuf, PROXY_H2_CHUNK_SIZE, H2_TUNNEL_SEND_CHUNKS);
- if(cf->conn->bits.conn_to_host)
- hostname = cf->conn->conn_to_host.name;
- else if(cf->sockindex == SECONDARYSOCKET)
- hostname = cf->conn->secondaryhostname;
- else
- hostname = cf->conn->host.name;
-
- if(cf->sockindex == SECONDARYSOCKET)
- port = cf->conn->secondary_port;
- else if(cf->conn->bits.conn_to_port)
- port = cf->conn->conn_to_port;
- else
- port = cf->conn->remote_port;
-
- if(hostname != cf->conn->host.name)
- ipv6_ip = (strchr(hostname, ':') != NULL);
+ result = Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
+ if(result)
+ return result;
ts->authority = /* host:port with IPv6 support */
aprintf("%s%s%s:%d", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"", port);
@@ -233,7 +221,7 @@ static void drain_tunnel(struct Curl_cfilter *cf, bits = CURL_CSELECT_IN;
if(!tunnel->closed && !tunnel->reset && tunnel->upload_blocked_len)
bits |= CURL_CSELECT_OUT;
- if(data->state.dselect_bits != bits || 1) {
+ if(data->state.dselect_bits != bits) {
CURL_TRC_CF(data, cf, "[%d] DRAIN dselect_bits=%x",
tunnel->stream_id, bits);
data->state.dselect_bits = bits;
@@ -309,8 +297,9 @@ static int proxy_h2_on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
void *userp);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
-static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame,
- void *userp);
+static int proxy_h2_on_frame_send(nghttp2_session *session,
+ const nghttp2_frame *frame,
+ void *userp);
#endif
static int proxy_h2_on_stream_close(nghttp2_session *session,
int32_t stream_id,
@@ -355,7 +344,8 @@ static CURLcode cf_h2_proxy_ctx_init(struct Curl_cfilter *cf, nghttp2_session_callbacks_set_on_frame_recv_callback(
cbs, proxy_h2_on_frame_recv);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- nghttp2_session_callbacks_set_on_frame_send_callback(cbs, on_frame_send);
+ nghttp2_session_callbacks_set_on_frame_send_callback(cbs,
+ proxy_h2_on_frame_send);
#endif
nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
cbs, tunnel_recv_callback);
@@ -575,7 +565,8 @@ static ssize_t on_session_send(nghttp2_session *h2, }
#ifndef CURL_DISABLE_VERBOSE_STRINGS
-static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen)
+static int proxy_h2_fr_print(const nghttp2_frame *frame,
+ char *buffer, size_t blen)
{
switch(frame->hd.type) {
case NGHTTP2_DATA: {
@@ -646,8 +637,9 @@ static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen) }
}
-static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame,
- void *userp)
+static int proxy_h2_on_frame_send(nghttp2_session *session,
+ const nghttp2_frame *frame,
+ void *userp)
{
struct Curl_cfilter *cf = userp;
struct Curl_easy *data = CF_DATA_CURRENT(cf);
@@ -657,7 +649,7 @@ static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame, if(data && Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = fr_print(frame, buffer, sizeof(buffer)-1);
+ len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
buffer[len] = 0;
CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer);
}
@@ -680,7 +672,7 @@ static int proxy_h2_on_frame_recv(nghttp2_session *session, if(Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = fr_print(frame, buffer, sizeof(buffer)-1);
+ len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
buffer[len] = 0;
CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer);
}
@@ -980,38 +972,11 @@ static CURLcode submit_CONNECT(struct Curl_cfilter *cf, CURLcode result;
struct httpreq *req = NULL;
- infof(data, "Establish HTTP/2 proxy tunnel to %s", ts->authority);
-
- result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT")-1,
- NULL, 0, ts->authority, strlen(ts->authority),
- NULL, 0);
+ result = Curl_http_proxy_create_CONNECT(&req, cf, data, 2);
if(result)
goto out;
- /* Setup the proxy-authorization header, if any */
- result = Curl_http_output_auth(data, cf->conn, req->method, HTTPREQ_GET,
- req->authority, TRUE);
- if(result)
- goto out;
-
- if(data->state.aptr.proxyuserpwd) {
- result = Curl_dynhds_h1_cadd_line(&req->headers,
- data->state.aptr.proxyuserpwd);
- if(result)
- goto out;
- }
-
- if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent"))
- && data->set.str[STRING_USERAGENT]) {
- result = Curl_dynhds_cadd(&req->headers, "User-Agent",
- data->set.str[STRING_USERAGENT]);
- if(result)
- goto out;
- }
-
- result = Curl_dynhds_add_custom(data, TRUE, &req->headers);
- if(result)
- goto out;
+ infof(data, "Establish HTTP/2 proxy tunnel to %s", req->authority);
result = proxy_h2_submit(&ts->stream_id, cf, data, ctx->h2, req,
NULL, ts, tunnel_send_callback, cf);
@@ -1058,7 +1023,7 @@ static CURLcode inspect_response(struct Curl_cfilter *cf, if(result)
return result;
if(data->req.newurl) {
- /* Inidicator that we should try again */
+ /* Indicator that we should try again */
Curl_safefree(data->req.newurl);
h2_tunnel_go_state(cf, ts, H2_TUNNEL_INIT, data);
return CURLE_OK;
@@ -1195,6 +1160,8 @@ static void cf_h2_proxy_close(struct Curl_cfilter *cf, struct Curl_easy *data) cf_h2_proxy_ctx_clear(ctx);
CF_DATA_RESTORE(cf, save);
}
+ if(cf->next)
+ cf->next->cft->do_close(cf->next, data);
}
static void cf_h2_proxy_destroy(struct Curl_cfilter *cf,
|