tests: change the behavior of swsbounce

- Change the swsbounce keyword to override the part number on a
  subsequent request to the previous part number + 1.

Note the previous part number in this case is the part number that
was returned as a response to the previous request and contained
the swsbounce keyword.

Prior to this change swsbounce incremented the part number of the
subsequent request instead of overriding it, and did so in a more
limited fashion that prevented chaining swsbounce in multiple responses.

For example, if the test makes a request that causes the sws server to
return `<data>` as a response and that response contains `swsbounce`
then for the next response the sws server returns `<data1>`. If
`<data1>` also contains `swsbounce` then for the next response the sws
server now returns `<data2>` instead of the requested part.

Fixes https://github.com/curl/curl/discussions/16074
Closes https://github.com/curl/curl/pull/16085
This commit is contained in:
Jay Satiro 2025-01-25 03:17:10 -05:00
parent 516cb98733
commit 1a36923d73
22 changed files with 165 additions and 50 deletions

View file

@ -268,6 +268,7 @@ test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
test3024 test3025 test3026 test3027 test3028 test3029 test3030 test3031 \
test3032 \
\
test3100 test3101 test3102 test3103 test3104 test3105 \
test3200 \

View file

@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -18,7 +18,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -40,7 +40,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -836,7 +836,7 @@ daniel
# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
</connect1000>
@ -847,7 +847,7 @@ Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Content-Length: 40000
X-tra-long-header: %repeat[16080 x a]%
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
HTTP/1.1 200 OK

View file

@ -841,7 +841,7 @@ daniel
# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
</connect1000>
@ -852,7 +852,7 @@ Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Transfer-Encoding: chunked
X-tra-long-header: %repeat[16080 x a]%
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
HTTP/1.1 200 OK

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -11,7 +11,7 @@ followlocation
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", qop="auth"
Content-Type: text/html; charset=iso-8859-1
@ -35,7 +35,7 @@ Content-Length: 0
</data1001>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", qop="auth"
Content-Type: text/html; charset=iso-8859-1

View file

@ -11,7 +11,7 @@ HTTP NTLM auth
<reply>
# the first request has NTLM type-1 included, and then the 1001 is returned
<data1001>
HTTP/1.1 200 beng swsclose swsbounce
HTTP/1.1 200 beng swsclose
Server: Microsoft-IIS/6.0
Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth
Content-Type: text/html; charset=iso-8859-1
@ -29,7 +29,7 @@ content for you
</data>
<datacheck>
HTTP/1.1 200 beng swsclose swsbounce
HTTP/1.1 200 beng swsclose
Server: Microsoft-IIS/6.0
Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth
Content-Type: text/html; charset=iso-8859-1

View file

@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144", userhash=true
Content-Type: text/html; charset=iso-8859-1
@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144", userhash=true
Content-Type: text/html; charset=iso-8859-1

View file

@ -41,7 +41,7 @@ daniel
# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
</connect1000>
@ -51,7 +51,7 @@ HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Content-Length: 33
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no
HTTP/1.1 200 OK

View file

@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-512-256", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-512-256", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256"
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256"
Content-Type: text/html; charset=iso-8859-1

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-512-256"
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-512-256"
Content-Type: text/html; charset=iso-8859-1

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256", userhash=true
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256", userhash=true
Content-Type: text/html; charset=iso-8859-1

View file

@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -27,7 +27,7 @@ ok
</data1000>
<datacheck>
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

View file

@ -15,7 +15,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1
@ -37,7 +37,7 @@ Server: Microsoft-IIS/5.0
Date: Sun, 03 Apr 2005 14:57:45 GMT
X-Powered-By: ASP.NET
HTTP/1.1 401 authentication please swsbounce
HTTP/1.1 401 authentication please
Server: Microsoft-IIS/6.0
WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
Content-Type: text/html; charset=iso-8859-1

112
tests/data/test3032 Normal file
View file

@ -0,0 +1,112 @@
<testcase>
<info>
<keywords>
HTTP
--location
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data
</data>
<data1>
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data1
</data1>
<data2>
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data2
</data2>
<data3>
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 30
Part: data3
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</data3>
<datacheck>
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data1
HTTP/1.1 301 redirect swsbounce
Content-Length: 0
Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
Part: data2
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 30
Part: data3
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
# This is a test of the swsbounce keyword which is used during tests to
# override the data response number for the next request to the previous
# data response number + 1. eg data, data1, data2 etc.
<name>
HTTP redirect loop 3x swsbounce test
</name>
<command>
--location http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
</verify>
</testcase>