From: Daniel Stenberg Date: Sun, 6 Feb 2022 15:02:04 +0000 (+0100) Subject: ngtcp2/quiche: make :scheme possible to set X-Git-Tag: curl-7_82_0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79731d1a6cfbab62297bc3d29788b8d6c8e9a0cb;p=thirdparty%2Fcurl.git ngtcp2/quiche: make :scheme possible to set --- diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c index 102310d73a..92a12f1ca8 100644 --- a/lib/vquic/ngtcp2.c +++ b/lib/vquic/ngtcp2.c @@ -45,6 +45,7 @@ #include "strerror.h" #include "dynbuf.h" #include "vquic.h" +#include "transfer.h" #include "vtls/keylog.h" /* The last 3 #include files should be in this order */ @@ -1394,6 +1395,7 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem, int64_t stream3_id; int rc; struct h3out *h3out = NULL; + char *vptr; rc = ngtcp2_conn_open_bidi_stream(qs->qconn, &stream3_id, NULL); if(rc) { @@ -1466,10 +1468,21 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem, nva[2].name = (unsigned char *)H3_PSEUDO_SCHEME; nva[2].namelen = sizeof(H3_PSEUDO_SCHEME) - 1; - if(conn->handler->flags & PROTOPT_SSL) - nva[2].value = (unsigned char *)"https"; - else - nva[2].value = (unsigned char *)"http"; + + vptr = Curl_checkheaders(data, H3_PSEUDO_SCHEME); + if(vptr) { + vptr += sizeof(H3_PSEUDO_SCHEME); + while(*vptr && ISSPACE(*vptr)) + vptr++; + nva[2].value = (unsigned char *)vptr; + infof(data, "set pseduo header %s to %s", H3_PSEUDO_SCHEME, vptr); + } + else { + if(conn->handler->flags & PROTOPT_SSL) + nva[2].value = (unsigned char *)"https"; + else + nva[2].value = (unsigned char *)"http"; + } nva[2].valuelen = strlen((char *)nva[2].value); nva[2].flags = NGHTTP3_NV_FLAG_NONE; diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c index 908c56bc9a..d2ef9169ce 100644 --- a/lib/vquic/quiche.c +++ b/lib/vquic/quiche.c @@ -36,6 +36,7 @@ #include "connect.h" #include "strerror.h" #include "vquic.h" +#include "transfer.h" #include "vtls/openssl.h" #include "vtls/keylog.h" @@ -709,8 +710,6 @@ void Curl_quic_ver(char *p, size_t len) static CURLcode http_request(struct Curl_easy *data, const void *mem, size_t len) { - /* - */ struct connectdata *conn = data->conn; struct HTTP *stream = data->req.p.http; size_t nheader; @@ -722,6 +721,7 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem, quiche_h3_header *nva = NULL; struct quicsocket *qs = conn->quic; CURLcode result = CURLE_OK; + char *vptr; stream->h3req = TRUE; /* senf off! */ @@ -783,13 +783,22 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem, nva[2].name = (unsigned char *)H3_PSEUDO_SCHEME; nva[2].name_len = sizeof(H3_PSEUDO_SCHEME) - 1; - if(conn->handler->flags & PROTOPT_SSL) - nva[2].value = (unsigned char *)"https"; - else - nva[2].value = (unsigned char *)"http"; + vptr = Curl_checkheaders(data, H3_PSEUDO_SCHEME); + if(vptr) { + vptr += sizeof(H3_PSEUDO_SCHEME); + while(*vptr && ISSPACE(*vptr)) + vptr++; + nva[2].value = (unsigned char *)vptr; + infof(data, "set pseduo header %s to %s", H3_PSEUDO_SCHEME, vptr); + } + else { + if(conn->handler->flags & PROTOPT_SSL) + nva[2].value = (unsigned char *)"https"; + else + nva[2].value = (unsigned char *)"http"; + } nva[2].value_len = strlen((char *)nva[2].value); - authority_idx = 0; i = 3; while(i < nheader) {