]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ngtcp2/quiche: make :scheme possible to set
authorDaniel Stenberg <daniel@haxx.se>
Sun, 6 Feb 2022 15:02:04 +0000 (16:02 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 7 Feb 2022 12:56:06 +0000 (13:56 +0100)
lib/vquic/ngtcp2.c
lib/vquic/quiche.c

index 102310d73a388568964f2e42b498d0c87aba4c74..92a12f1ca84857731eda8f245343bfa497618ab4 100644 (file)
@@ -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;
 
index 908c56bc9a5bfa783d0267d852691758f5492592..d2ef9169ce38dc61dabb590a00473f4e9124eced 100644 (file)
@@ -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) {