http2: header conversion tightening

- fold the code to convert dynhds to the nghttp2 structs
  into a dynhds internal method
- saves code duplication
- pacifies compiler analyzers

Closes #12097
This commit is contained in:
Stefan Eissing 2023-10-12 10:15:05 +02:00 committed by Daniel Stenberg
parent f76fcd6f4d
commit 117c9bd978
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 40 additions and 23 deletions

View file

@ -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;
}
if(read_callback) {
nghttp2_data_provider data_prd;