http: on 303, switch to GET

... unless it is a POST and the user explicitly asked to keep doing
POST.

Add test1983/1984: verify --follow with 303 and PUT + custom GET

Fixes #20715
Reported-by: Dan Arnfield
Closes #21280
This commit is contained in:
Daniel Stenberg 2026-04-09 23:43:55 +02:00
parent bb3670f929
commit e5087ac9fc
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 169 additions and 24 deletions

View file

@ -241,7 +241,7 @@ test1941 test1942 test1943 test1944 test1945 test1946 test1947 test1948 \
test1955 test1956 test1957 test1958 test1959 test1960 test1964 test1965 \
\
test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
test1978 test1979 test1980 test1981 test1982 \
test1978 test1979 test1980 test1981 test1982 test1983 test1984 \
\
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
test2008 \

71
tests/data/test1983 Normal file
View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP DELETE
followlocation
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 303 OK swsclose
Location: moo.html%AMPtestcase=/%TESTNUMBER0002
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
</data>
<data2>
HTTP/1.1 200 OK swsclose
Location: this should be ignored
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
body
</data2>
<datacheck>
HTTP/1.1 303 OK swsclose
Location: moo.html%AMPtestcase=/%TESTNUMBER0002
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
HTTP/1.1 200 OK swsclose
Location: this should be ignored
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
body
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
HTTP DELETE with --follow and 303 redirect
</name>
<command>
http://%HOSTIP:%HTTPPORT/blah/%TESTNUMBER --follow -X DELETE
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="yes">
DELETE /blah/%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
GET /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
</verify>
</testcase>

76
tests/data/test1984 Normal file
View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP PUT
followlocation
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 303 OK swsclose
Location: moo.html%AMPtestcase=/%TESTNUMBER0002
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
</data>
<data2>
HTTP/1.1 200 OK swsclose
Location: this should be ignored
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
body
</data2>
<datacheck>
HTTP/1.1 303 OK swsclose
Location: moo.html%AMPtestcase=/%TESTNUMBER0002
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
HTTP/1.1 200 OK swsclose
Location: this should be ignored
Date: Tue, 09 Nov 2010 14:49:00 GMT
Connection: close
body
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
HTTP PUT with 303 redirect and --follow
</name>
<command>
http://%HOSTIP:%HTTPPORT/blah/%TESTNUMBER --follow -T %LOGDIR/upload
</command>
<file name="%LOGDIR/upload">
Except for responses to a HEAD request, the representation of a 303 response ought to contain a short hypertext note with a hyperlink to the same URI reference provided in the Location header field.
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="headers">
PUT /blah/%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 199
Except for responses to a HEAD request, the representation of a 303 response ought to contain a short hypertext note with a hyperlink to the same URI reference provided in the Location header field.
GET /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
</verify>
</testcase>