-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,49 @@ | ||
diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c | ||
index dbc895d2634d93..9f852c1a588e6d 100644 | ||
--- a/lib/cf-h2-proxy.c | ||
+++ b/lib/cf-h2-proxy.c | ||
@@ -909,7 +909,6 @@ static CURLcode proxy_h2_submit(int32_t *pstream_id, | ||
{ | ||
struct dynhds h2_headers; | ||
nghttp2_nv *nva = NULL; | ||
- unsigned int i; | ||
int32_t stream_id = -1; | ||
size_t nheader; | ||
CURLcode result; | ||
@@ -920,22 +919,12 @@ static CURLcode proxy_h2_submit(int32_t *pstream_id, | ||
if(result) | ||
goto out; | ||
|
||
- nheader = Curl_dynhds_count(&h2_headers); | ||
- nva = malloc(sizeof(nghttp2_nv) * nheader); | ||
+ nva = Curl_dynhds_to_nva(&h2_headers, &nheader); | ||
if(!nva) { | ||
result = CURLE_OUT_OF_MEMORY; | ||
goto out; | ||
} | ||
|
||
- for(i = 0; i < nheader; ++i) { | ||
- struct dynhds_entry *e = Curl_dynhds_getn(&h2_headers, i); | ||
- nva[i].name = (unsigned char *)e->name; | ||
- nva[i].namelen = e->namelen; | ||
- nva[i].value = (unsigned char *)e->value; | ||
- nva[i].valuelen = e->valuelen; | ||
- nva[i].flags = NGHTTP2_NV_FLAG_NONE; | ||
commit 8161912af3d8c468a24bc94ee5b660664c7f410f | ||
Author: Viktor Szakats <[email protected]> | ||
Date: 2023-10-16 08:15:16 +0000 | ||
|
||
Revert "resolve: use PF_INET6 family lookups when CURL_IPRESOLVE_V6 is set" | ||
|
||
This reverts commit d3142b57299f3aeec546cc1179b9ff170f8d20ad. | ||
|
||
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c | ||
index e73e41dab..516e4ce6f 100644 | ||
--- a/lib/asyn-ares.c | ||
+++ b/lib/asyn-ares.c | ||
@@ -775,14 +775,9 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, | ||
int pf = PF_INET; | ||
memset(&hints, 0, sizeof(hints)); | ||
#ifdef CURLRES_IPV6 | ||
- if((data->conn->ip_version != CURL_IPRESOLVE_V4) && | ||
- Curl_ipv6works(data)) { | ||
+ if((data->conn->ip_version != CURL_IPRESOLVE_V4) && Curl_ipv6works(data)) | ||
/* The stack seems to be IPv6-enabled */ | ||
- if(data->conn->ip_version == CURL_IPRESOLVE_V6) | ||
- pf = PF_INET6; | ||
- else | ||
- pf = PF_UNSPEC; | ||
- } | ||
+ pf = PF_UNSPEC; | ||
#endif /* CURLRES_IPV6 */ | ||
hints.ai_family = pf; | ||
hints.ai_socktype = (data->conn->transport == TRNSPRT_TCP)? | ||
diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c | ||
index a2e294f8f..6f0a2126a 100644 | ||
--- a/lib/asyn-thread.c | ||
+++ b/lib/asyn-thread.c | ||
@@ -696,13 +696,9 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, | ||
*waitp = 0; /* default to synchronous response */ | ||
|
||
#ifdef CURLRES_IPV6 | ||
- if((data->conn->ip_version != CURL_IPRESOLVE_V4) && Curl_ipv6works(data)) { | ||
+ if((data->conn->ip_version != CURL_IPRESOLVE_V4) && Curl_ipv6works(data)) | ||
/* The stack seems to be IPv6-enabled */ | ||
- if(data->conn->ip_version == CURL_IPRESOLVE_V6) | ||
- pf = PF_INET6; | ||
- else | ||
- pf = PF_UNSPEC; | ||
- } | ||
- | ||
if(read_callback) { | ||
nghttp2_data_provider data_prd; | ||
|
||
diff --git a/lib/dynhds.c b/lib/dynhds.c | ||
index 979b3e825bbcca..7ed588e74e0bdd 100644 | ||
--- a/lib/dynhds.c | ||
+++ b/lib/dynhds.c | ||
@@ -27,6 +27,10 @@ | ||
#include "strcase.h" | ||
|
||
/* The last 3 #include files should be in this order */ | ||
+#ifdef USE_NGHTTP2 | ||
+#include <stdint.h> | ||
+#include <nghttp2/nghttp2.h> | ||
+#endif /* USE_NGHTTP2 */ | ||
#include "curl_printf.h" | ||
#include "curl_memory.h" | ||
#include "memdebug.h" | ||
@@ -365,3 +369,26 @@ CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf) | ||
return result; | ||
} | ||
+ pf = PF_UNSPEC; | ||
#endif /* CURLRES_IPV6 */ | ||
|
||
+#ifdef USE_NGHTTP2 | ||
+ | ||
+nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount) | ||
+{ | ||
+ nghttp2_nv *nva = calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len); | ||
+ size_t i; | ||
+ | ||
+ *pcount = 0; | ||
+ if(!nva) | ||
+ return NULL; | ||
+ | ||
+ for(i = 0; i < dynhds->hds_len; ++i) { | ||
+ nva[i].name = (unsigned char *)dynhds->hds[i]->name; | ||
+ nva[i].namelen = dynhds->hds[i]->namelen; | ||
+ nva[i].value = (unsigned char *)dynhds->hds[i]->value; | ||
+ nva[i].valuelen = dynhds->hds[i]->valuelen; | ||
+ nva[i].flags = NGHTTP2_NV_FLAG_NONE; | ||
+ } | ||
+ *pcount = dynhds->hds_len; | ||
+ return nva; | ||
+} | ||
+ | ||
+#endif /* USE_NGHTTP2 */ | ||
diff --git a/lib/dynhds.h b/lib/dynhds.h | ||
index 8a053480e995fb..3b536000a2e4c0 100644 | ||
--- a/lib/dynhds.h | ||
+++ b/lib/dynhds.h | ||
@@ -171,4 +171,13 @@ CURLcode Curl_dynhds_h1_add_line(struct dynhds *dynhds, | ||
*/ | ||
CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf); | ||
|
||
+#ifdef USE_NGHTTP2 | ||
+ | ||
+#include <stdint.h> | ||
+#include <nghttp2/nghttp2.h> | ||
+ | ||
+nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount); | ||
+ | ||
+#endif /* USE_NGHTTP2 */ | ||
+ | ||
#endif /* HEADER_CURL_DYNHDS_H */ | ||
diff --git a/lib/http2.c b/lib/http2.c | ||
index c8b059498f0177..66d4f996b4d1b1 100644 | ||
--- a/lib/http2.c | ||
+++ b/lib/http2.c | ||
@@ -2052,23 +2052,13 @@ static ssize_t h2_submit(struct stream_ctx **pstream, | ||
/* no longer needed */ | ||
Curl_h1_req_parse_free(&stream->h1); | ||
|
||
- nheader = Curl_dynhds_count(&h2_headers); | ||
- nva = malloc(sizeof(nghttp2_nv) * nheader); | ||
+ nva = Curl_dynhds_to_nva(&h2_headers, &nheader); | ||
if(!nva) { | ||
*err = CURLE_OUT_OF_MEMORY; | ||
nwritten = -1; | ||
goto out; | ||
} | ||
|
||
- for(i = 0; i < nheader; ++i) { | ||
- struct dynhds_entry *e = Curl_dynhds_getn(&h2_headers, i); | ||
- nva[i].name = (unsigned char *)e->name; | ||
- nva[i].namelen = e->namelen; | ||
- nva[i].value = (unsigned char *)e->value; | ||
- nva[i].valuelen = e->valuelen; | ||
- nva[i].flags = NGHTTP2_NV_FLAG_NONE; | ||
- } | ||
- | ||
h2_pri_spec(data, &pri_spec); | ||
if(!nghttp2_session_check_request_allowed(ctx->h2)) | ||
CURL_TRC_CF(data, cf, "send request NOT allowed (via nghttp2)"); | ||
memset(&hints, 0, sizeof(hints)); |