From 5345b04a43765afbb13f956d6f15160e8e56f3d5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 3 Mar 2019 11:17:52 +0100 Subject: alt-svc: add test 355 and 356 to verify with command line curl --- lib/http.c | 9 ++++++- tests/data/Makefile.inc | 2 +- tests/data/test355 | 57 ++++++++++++++++++++++++++++++++++++++++ tests/data/test356 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 tests/data/test355 create mode 100644 tests/data/test356 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 @@ + + + +HTTP +Alt-Svc + + + +# +# Server-side + + +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- + + + +# +# Client-side + + +alt-svc + + +http + + +load Alt-Svc from file and use + + +http://%HOSTIP:%HTTPPORT/355 --alt-svc "" + + +h1 example.com 80 h1 %HOSTIP %HTTPPORT "20290222 22:19:28" 0 0 + + + +# +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +GET /355 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + + + + 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 @@ + + + +HTTP +Alt-Svc + + + +# +# Server-side + + +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- + + + +# +# Client-side + + +debug +alt-svc + + +http + + +parse incoming Alt-Svc and save to file + + +# make debug-curl accept Alt-Svc over plain HTTP +CURL_ALTSVC_HTTP="yeah" + +http://%HOSTIP:%HTTPPORT/356 --alt-svc "log/altsvc-356" + + + +# +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +GET /356 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + + + +# strip out the (dynamic) expire date from the file so that the rest +# matches +s/\"([^\"]*)\"/TIMESTAMP/ + + +# 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 + + + -- cgit v1.2.3