mirror of
https://github.com/curl/curl.git
synced 2026-07-23 18:17:15 +03:00
Philip Langdale provided the new CURLOPT_POST301 option for
curl_easy_setopt() that alters how libcurl functions when following redirects. It makes libcurl obey the RFC2616 when a 301 response is received after a non-GET request is made. Default libcurl behaviour is to change method to GET in the subsequent request (like it does for response code 302 - because that's what many/most browsers do), but with this CURLOPT_POST301 option enabled it will do what the spec says and do the next request using the same method again. I.e keep POST after 301. The curl tool got this option as --post301 Test case 1011 and 1012 were added to verify.
This commit is contained in:
parent
a6315359d7
commit
fd4cf78f36
11 changed files with 213 additions and 19 deletions
|
|
@ -44,4 +44,4 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
|
|||
test409 test613 test614 test700 test701 test702 test704 test705 test703 \
|
||||
test706 test707 test350 test351 test352 test353 test289 test540 test354 \
|
||||
test231 test1000 test1001 test1002 test1003 test1004 test1005 test1006 \
|
||||
test615 test1007 test541 test1010
|
||||
test615 test1007 test541 test1010 test1011 test1012
|
||||
|
|
|
|||
76
tests/data/test1011
Normal file
76
tests/data/test1011
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
HTTP POST
|
||||
followlocation
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
HTTP/1.1 301 OK swsclose
|
||||
Location: moo.html&testcase=/10110002
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Location: this should be ignored
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
body
|
||||
</data2>
|
||||
<datacheck>
|
||||
HTTP/1.1 301 OK swsclose
|
||||
Location: moo.html&testcase=/10110002
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Location: this should be ignored
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
body
|
||||
</datacheck>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<name>
|
||||
HTTP POST with 301 redirect
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/blah/1011 -L -d "moo"
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
POST /blah/1011 HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
Content-Length: 3
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mooGET /blah/moo.html&testcase=/10110002 HTTP/1.1
|
||||
User-Agent: curl/7.10 (i686-pc-linux-gnu) libcurl/7.10 OpenSSL/0.9.6c ipv6 zlib/1.1.3
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
79
tests/data/test1012
Normal file
79
tests/data/test1012
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
HTTP POST
|
||||
followlocation
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
HTTP/1.1 301 OK swsclose
|
||||
Location: moo.html&testcase=/10120002
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Location: this should be ignored
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
body
|
||||
</data2>
|
||||
<datacheck>
|
||||
HTTP/1.1 301 OK swsclose
|
||||
Location: moo.html&testcase=/10120002
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
HTTP/1.1 200 OK swsclose
|
||||
Location: this should be ignored
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Connection: close
|
||||
|
||||
body
|
||||
</datacheck>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<name>
|
||||
HTTP POST with 301 redirect and --post301
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/blah/1012 -L -d "moo" --post301
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
</strip>
|
||||
<protocol nonewline="yes">
|
||||
POST /blah/1012 HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
Content-Length: 3
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mooPOST /blah/moo.html&testcase=/10120002 HTTP/1.1
|
||||
User-Agent: curl/7.10 (i686-pc-linux-gnu) libcurl/7.10 OpenSSL/0.9.6c ipv6 zlib/1.1.3
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
Content-Length: 3
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
moo
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue