]> granicus.if.org Git - curl/commitdiff
alt-svc: add test 355 and 356 to verify with command line curl
authorDaniel Stenberg <daniel@haxx.se>
Sun, 3 Mar 2019 10:17:52 +0000 (11:17 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 3 Mar 2019 10:17:52 +0000 (11:17 +0100)
lib/http.c
tests/data/Makefile.inc
tests/data/test355 [new file with mode: 0644]
tests/data/test356 [new file with mode: 0644]

index f5709b68b47f621d5d365be1925cce3bb89a333b..3618f8728bbf2c4f17167f1f17393b7a397c8f3f 100644 (file)
@@ -3982,7 +3982,14 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
 #ifdef USE_ALTSVC
     /* If enabled, the header is incoming and this is over HTTPS */
     else if(data->asi && checkprefix("Alt-Svc:", k->p) &&
-            (conn->handler->flags & PROTOPT_SSL)) {
+            ((conn->handler->flags & PROTOPT_SSL) ||
+#ifdef CURLDEBUG
+             /* allow debug builds to circumvent the HTTPS restriction */
+             getenv("CURL_ALTSVC_HTTP")
+#else
+             0
+#endif
+              )) {
       /* the ALPN of the current request */
       enum alpnid id = (conn->httpversion == 20) ? ALPN_h2 : ALPN_h1;
       result = Curl_altsvc_parse(data, data->asi,
index bd24b4ba20ce3ab8941f21a30a23325d2f50e0d3..29e8c6924d7a65b429dab55efd0b2e6950f4553d 100644 (file)
@@ -60,7 +60,7 @@ test325 test326 test327 test328 test329 test330 \
 \
 test340 \
 \
-test350 test351 test352 test353 test354 \
+test350 test351 test352 test353 test354 test355 test356 \
 test393 test394 test395 \
 \
 test400 test401 test402 test403 test404 test405 test406 test407 test408 \
diff --git a/tests/data/test355 b/tests/data/test355
new file mode 100644 (file)
index 0000000..e9c4cb2
--- /dev/null
@@ -0,0 +1,57 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+Alt-Svc
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<features>
+alt-svc
+</features>
+<server>
+http
+</server>
+ <name>
+load Alt-Svc from file and use
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/355 --alt-svc ""
+</command>
+<file name="log/altsvc-355">
+h1 example.com 80 h1 %HOSTIP %HTTPPORT "20290222 22:19:28" 0 0
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /355 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test356 b/tests/data/test356
new file mode 100644 (file)
index 0000000..26305f9
--- /dev/null
@@ -0,0 +1,69 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+Alt-Svc
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+Alt-Svc: h1="nowhere.foo:81"
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<features>
+debug
+alt-svc
+</features>
+<server>
+http
+</server>
+ <name>
+parse incoming Alt-Svc and save to file
+ </name>
+<setenv>
+# make debug-curl accept Alt-Svc over plain HTTP
+CURL_ALTSVC_HTTP="yeah"
+ <command>
+http://%HOSTIP:%HTTPPORT/356 --alt-svc "log/altsvc-356"
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /356 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+</protocol>
+<stripfile>
+# strip out the (dynamic) expire date from the file so that the rest
+# matches
+s/\"([^\"]*)\"/TIMESTAMP/
+</stripfile>
+<file name="log/altsvc-356">
+# Your alt-svc cache. https://curl.haxx.se/docs/alt-svc.html
+# This file was generated by libcurl! Edit at your own risk.
+h1 %HOSTIP %HTTPPORT h1 nowhere.foo 81 TIMESTAMP 0 0
+</file>
+</verify>
+</testcase>