]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CURLOPT_HTTP_VERSION: seting this to 3 forces HTTP/3 use directly
authorDaniel Stenberg <daniel@haxx.se>
Wed, 7 Aug 2019 12:17:48 +0000 (14:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 8 Aug 2019 06:17:24 +0000 (08:17 +0200)
Even though it cannot fall-back to a lower HTTP version automatically. The
safer way to upgrade remains via CURLOPT_ALTSVC.

CURLOPT_H3 no longer has any bits that do anything and might be removed
before we remove the experimental label.

Updated the curl tool accordingly to use "--http3".

Closes #4197

16 files changed:
docs/HTTP3.md
docs/cmdline-opts/Makefile.inc
docs/cmdline-opts/http2.d
docs/cmdline-opts/http3.d [moved from docs/cmdline-opts/http3-direct.d with 74% similarity]
docs/libcurl/opts/CURLINFO_HTTP_VERSION.3
docs/libcurl/opts/CURLOPT_H3.3
docs/libcurl/opts/CURLOPT_HTTP_VERSION.3
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/http.c
lib/setopt.c
lib/urldata.h
src/tool_cfgable.h
src/tool_getparam.c
src/tool_help.c
src/tool_operate.c

index aa13033976c4cd4d76dde72689f4f46905148981..092d4d3e4d83c56e59029fcc476ae58b49ca7a31 100644 (file)
@@ -45,7 +45,7 @@ you'll just get ld.so linker errors.
 
 ## Invoke from command line
 
-    curl --http3-direct https://nghttp2.org:8443/
+    curl --http3 https://nghttp2.org:8443/
 
 # quiche version
 
@@ -79,7 +79,7 @@ Clone and build curl:
 
 Make an HTTP/3 request.
 
-     % src/curl --http3-direct https://cloudflare-quic.com/
-     % src/curl --http3-direct https://facebook.com/
-     % src/curl --http3-direct https://quic.aiortc.org:4433/
-     % src/curl --http3-direct https://quic.rocks:4433/
+     % src/curl --http3 https://cloudflare-quic.com/
+     % src/curl --http3 https://facebook.com/
+     % src/curl --http3 https://quic.aiortc.org:4433/
+     % src/curl --http3 https://quic.rocks:4433/
index 1bdda9885f08ff445a8cbab2624a33a3694600d0..6b43874751ef2dbfb80f1cd2a0bc0202bcfd85d7 100644 (file)
@@ -65,7 +65,7 @@ DPAGES =                                      \
   http1.0.d                                    \
   http1.1.d http2.d                            \
   http2-prior-knowledge.d                      \
-  http3-direct.d                                \
+  http3.d                                       \
   ignore-content-length.d                      \
   include.d                                    \
   insecure.d                                   \
index 04cff00a4f7dbf0c564e4e89ea36b74323cb4bb8..cf8f2988e627cebb7d0fe0a95a40b96cbfa8e4e5 100644 (file)
@@ -6,5 +6,6 @@ Mutexed: http1.1 http1.0 http2-prior-knowledge
 Requires: HTTP/2
 See-also: no-alpn
 Help: Use HTTP 2
+See-also: http1.1 http3
 ---
 Tells curl to use HTTP version 2.
similarity index 74%
rename from docs/cmdline-opts/http3-direct.d
rename to docs/cmdline-opts/http3.d
index fb8c8cf28fbe4570b0dda34c0e879bf88fa734bf..ca85e3a6422a562bea9009bd2204ebfa8fb939ad 100644 (file)
@@ -1,10 +1,11 @@
-Long: http3-direct
+Long: http3
 Tags: Versions
 Protocols: HTTP
 Added: 7.66.0
 Mutexed: http1.1 http1.0 http2 http2-prior-knowledge
 Requires: HTTP/3
 Help: Use HTTP v3
+See-also: http1.1 http2
 ---
 
 WARNING: this option is experiemental. Do not use in production.
@@ -14,3 +15,5 @@ the URL. A normal HTTP/3 transaction will be done to a host and then get
 redirected via Alt-SVc, but this option allows a user to circumvent that when
 you know that the target speaks HTTP/3 on the given host and port.
 
+This option will make curl fail if a QUIC connection cannot be established, it
+cannot fall back to a lower HTTP version on its own.
index b0f43e549d39b202dc0888e78d097ddbab0f47ef..7e8931812074f43d2b1e5e3472949fb3914ad45b 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -28,9 +28,10 @@ CURLINFO_HTTP_VERSION \- get the http version used in the connection
 
 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p);
 .SH DESCRIPTION
-Pass a pointer to a long to receive the version used in the last http connection.
-The returned value will be CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, or
-CURL_HTTP_VERSION_2_0, or 0 if the version can't be determined.
+Pass a pointer to a long to receive the version used in the last http
+connection.  The returned value will be CURL_HTTP_VERSION_1_0,
+CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0, CURL_HTTP_VERSION_3 or 0 if the
+version can't be determined.
 .SH PROTOCOLS
 HTTP
 .SH EXAMPLE
index be521b6bfacc3c376350a052adc36478b5693abf..3411073fdd7bc49c9a2a2a7bf52627ead4bf1e53 100644 (file)
@@ -35,10 +35,6 @@ production before the experimental label is removed.
 .SH DESCRIPTION
 This function accepts a long \fIbitmask\fP with a set of flags set that
 controls the HTTP/3 behavior for this transfer.
-.IP "CURLH3_DIRECT"
-If this bit is set in \fIbitmask\fP, the host name and port number given in
-the URL will be used to connect to directly with QUIC and the port number then
-being a UDP port number.
 .SH DEFAULT
 0
 .SH PROTOCOLS
@@ -49,7 +45,7 @@ CURL *curl = curl_easy_init();
 if(curl) {
   CURLcode ret;
   curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
-  curl_easy_setopt(curl, CURLOPT_H3, (long)CURLH3_DIRECT);
+  curl_easy_setopt(curl, CURLOPT_H3, (long)0);
   ret = curl_easy_perform(curl);
 }
 .fi
index 741dfaa6cf1480ade1900d6538a66f52aa073873..564c0dc1617c08c78160d1b5df882982fc55e08b 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -57,6 +57,14 @@ Issue non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires
 prior knowledge that the server supports HTTP/2 straight away. HTTPS requests
 will still do HTTP/2 the standard way with negotiated protocol version in the
 TLS handshake. (Added in 7.49.0)
+.IP CURL_HTTP_VERSION_3
+(Added in 7.66.0) Setting this value will make libcurl attempt to use HTTP/3
+directly to server given in the URL. Note that this cannot gracefully
+downgrade to earlier HTTP version if the server doesn't support HTTP/3.
+
+For more reliably upgrading into HTTP/3, set the prefered version to something
+lower and let the server announce its HTTP/3 support via Alt-Svc:. See
+\fICURLOPT_ALTSVC(3)\fP.
 .SH DEFAULT
 Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
 
@@ -82,4 +90,4 @@ Along with HTTP
 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
 .SH "SEE ALSO"
 .BR CURLOPT_SSLVERSION "(3), " CURLOPT_HTTP200ALIASES "(3), "
-.BR CURLOPT_HTTP09_ALLOWED "(3), "
+.BR CURLOPT_HTTP09_ALLOWED "(3), " CURLOPT_H3 "(3), " CURLOPT_ALTSVC "(3) "
index 79243e25b8b6ebdf13a43da8f9fa34120ee06527..9a4cec2b0964288a769d268928201017aa5f5489 100644 (file)
@@ -209,7 +209,6 @@ CURLFTP_CREATE_DIR_RETRY        7.19.4
 CURLGSSAPI_DELEGATION_FLAG      7.22.0
 CURLGSSAPI_DELEGATION_NONE      7.22.0
 CURLGSSAPI_DELEGATION_POLICY_FLAG 7.22.0
-CURLH3_DIRECT                   7.66.0
 CURLHEADER_SEPARATE             7.37.0
 CURLHEADER_UNIFIED              7.37.0
 CURLINFO_ACTIVESOCKET           7.45.0
index 9b9ec80c059b454ec0b51d6d164f7e0e2138c134..14703fd178568d952f669158423e332cfe44f29b 100644 (file)
@@ -921,8 +921,6 @@ typedef enum {
 #define CURLPROTO_ALL    (~0) /* enable everything */
 
 /* bitmask defines for CURLOPT_H3 */
-#define CURLH3_DIRECT (1<<0) /* go QUIC + HTTP/3 directly to the given host +
-                                port */
 
 /* long may be 32 or 64 bits, but we should never depend on anything else
    but 32 */
@@ -1985,9 +1983,8 @@ enum {
   CURL_HTTP_VERSION_2TLS, /* use version 2 for HTTPS, version 1.1 for HTTP */
   CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE,  /* please use HTTP 2 without HTTP/1.1
                                            Upgrade */
-  CURL_HTTP_VERSION_3 = 30, /* This cannot be set with CURLOPT_HTTP_VERSION,
-                               use CURLOPT_H3 and/or CURLOPT_ALTSVC to enable
-                               HTTP/3 */
+  CURL_HTTP_VERSION_3 = 30, /* Makes use of explicit HTTP/3 without fallback.
+                               Use CURLOPT_ALTSVC to enable HTTP/3 upgrade */
   CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
 };
 
index cfa7093b2a8e7b0cf06dfffa7215995f73e16f98..546c34aadfe634c09cf250ef22b2bb67bf175820 100644 (file)
@@ -169,10 +169,10 @@ static CURLcode http_setup_conn(struct connectdata *conn)
   Curl_mime_initpart(&http->form, conn->data);
   data->req.protop = http;
 
-  if(data->set.h3opts & CURLH3_DIRECT) {
+  if(data->set.httpversion == CURL_HTTP_VERSION_3) {
     if(conn->handler->flags & PROTOPT_SSL)
-      /* Only go h3-direct on HTTPS URLs. It needs a UDP socket and does the
-         QUIC dance. */
+      /* Only go HTTP/3 directly on HTTPS URLs. It needs a UDP socket and does
+         the QUIC dance. */
       conn->transport = TRNSPRT_QUIC;
     else {
       failf(data, "HTTP/3 requested for non-HTTPS URL");
index 91251bd7b2d8ea803a4416da71e1a96fdab2a2f9..1ad721131ef50258875703c3ecfa4759b490c963 100644 (file)
@@ -809,6 +809,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
     arg = va_arg(param, long);
     if(arg < CURL_HTTP_VERSION_NONE)
       return CURLE_BAD_FUNCTION_ARGUMENT;
+#ifdef ENABLE_QUIC
+    if(arg == CURL_HTTP_VERSION_3)
+      ;
+    else
+#endif
 #ifndef USE_NGHTTP2
     if(arg >= CURL_HTTP_VERSION_2)
       return CURLE_UNSUPPORTED_PROTOCOL;
@@ -2752,8 +2757,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
 #endif
   case CURLOPT_H3:
 #ifdef ENABLE_QUIC
-    arg = va_arg(param, long);
-    data->set.h3opts = arg;
+    /* not use anymore */
 #else
     return CURLE_NOT_BUILT_IN;
 #endif
index fec3f755a49b64daf405c8b48e61310c16938f04..395664d04d986e2059394c252215bccc78cc9fa8 100644 (file)
@@ -1680,7 +1680,6 @@ struct UserDefined {
   CURLU *uh; /* URL handle for the current parsed URL */
   void *trailer_data; /* pointer to pass to trailer data callback */
   curl_trailer_callback trailer_callback; /* trailing data callback */
-  long h3opts; /* the CURLOPT_H3 bitmask */
   bit is_fread_set:1; /* has read callback been set to non-NULL? */
   bit is_fwrite_set:1; /* has write callback been set to non-NULL? */
   bit free_referer:1; /* set TRUE if 'referer' points to a string we
index f6248c20ba6fdb1cdd0c3a7532a1f2c14a533455..ff80f8eb8a4c2ef59d06b40651d9dc1f572e77b7 100644 (file)
@@ -259,7 +259,6 @@ struct OperationConfig {
                                      0 is valid. default: CURL_HET_DEFAULT. */
   bool haproxy_protocol;          /* whether to send HAProxy protocol v1 */
   bool disallow_username_in_url;  /* disallow usernames in URLs */
-  bool h3direct;                  /* go HTTP/3 directly */
   struct GlobalConfig *global;
   struct OperationConfig *prev;
   struct OperationConfig *next;   /* Always last in the struct */
index 952e602ed248152e232c9d3d54506d7239c2d294..2c1868383df1260c5e9a98b2ac7cc3adc56acaf9 100644 (file)
@@ -201,7 +201,7 @@ static const struct LongShort aliases[]= {
   {"01",  "http1.1",                 ARG_NONE},
   {"02",  "http2",                   ARG_NONE},
   {"03",  "http2-prior-knowledge",   ARG_NONE},
-  {"04",  "http3-direct",            ARG_NONE},
+  {"04",  "http3",                   ARG_NONE},
   {"09",  "http0.9",                 ARG_BOOL},
   {"1",  "tlsv1",                    ARG_NONE},
   {"10",  "tlsv1.0",                 ARG_NONE},
@@ -1198,9 +1198,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
         /* HTTP version 2.0 over clean TCP*/
         config->httpversion = CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE;
         break;
-      case '4': /* --http3-direct */
-        /* HTTP version 3 over QUIC - at once */
-        config->h3direct = toggle;
+      case '4': /* --http3 */
+        /* HTTP version 3 go over QUIC - at once */
+        config->httpversion = CURL_HTTP_VERSION_3;
         break;
       case '9':
         /* Allow HTTP/0.9 responses! */
index 86bd692d93966db3b5da019a4d1828960cdb272c..cb0afef56615a8744f871570253724c25032b9c2 100644 (file)
@@ -191,7 +191,7 @@ static const struct helptxt helptext[] = {
    "Use HTTP 2"},
   {"    --http2-prior-knowledge",
    "Use HTTP 2 without HTTP/1.1 Upgrade"},
-  {"    --http3-direct",
+  {"    --http3",
    "Use HTTP v3"},
   {"    --ignore-content-length",
    "Ignore the size of the remote resource"},
index 01ee200615b1db14b763fbf7e870ae900d08d6a1..c9189bdeee015f95c60b2c9ddaf0fe1385322feb 100644 (file)
@@ -1132,9 +1132,6 @@ static CURLcode create_transfers(struct GlobalConfig *global,
         if(config->tcp_fastopen)
           my_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
 
-        if(config->h3direct)
-          my_setopt(curl, CURLOPT_H3, CURLH3_DIRECT);
-
         /* where to store */
         my_setopt(curl, CURLOPT_WRITEDATA, per);
         my_setopt(curl, CURLOPT_INTERLEAVEDATA, per);