Unverified Commit 5345b04a authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

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

parent c51c78dd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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 \

tests/data/test355

0 → 100644
+57 −0
Original line number Diff line number Diff line
<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>

tests/data/test356

0 → 100644
+69 −0
Original line number Diff line number Diff line
<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>