summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-03-03 11:17:52 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-03-03 11:17:52 +0100
commit5345b04a43765afbb13f956d6f15160e8e56f3d5 (patch)
tree0d73ef4925c5867783a8b2cd7a395be4c33ed097
parentc51c78dd8d93990d7168a7f6b2410ec437e66939 (diff)
downloadcurl-5345b04a43765afbb13f956d6f15160e8e56f3d5.tar.gz
alt-svc: add test 355 and 356 to verify with command line curl
-rw-r--r--lib/http.c9
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test35557
-rw-r--r--tests/data/test35669
4 files changed, 135 insertions, 2 deletions
diff --git a/lib/http.c b/lib/http.c
index f5709b68b..3618f8728 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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,
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index bd24b4ba2..29e8c6924 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -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
index 000000000..e9c4cb28f
--- /dev/null
+++ b/tests/data/test355
@@ -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
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test356 b/tests/data/test356
new file mode 100644
index 000000000..26305f96a
--- /dev/null
+++ b/tests/data/test356
@@ -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
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</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>