Skip to content
Permalink
Browse files

alt-svc: add test 355 and 356 to verify with command line curl

  • Loading branch information...
bagder committed Mar 3, 2019
1 parent c51c78d commit 5345b04a43765afbb13f956d6f15160e8e56f3d5
Showing with 135 additions and 2 deletions.
  1. +8 −1 lib/http.c
  2. +1 −1 tests/data/Makefile.inc
  3. +57 −0 tests/data/test355
  4. +69 −0 tests/data/test356
@@ -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,
@@ -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 \
@@ -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>
@@ -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>

0 comments on commit 5345b04

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.