Commit fd4cf78f authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

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.
parent a6315359
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -7,6 +7,19 @@
                                  Changelog

Daniel S (26 September 2007)
- 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.

- Max Katsev reported that when doing a libcurl FTP request with
  CURLOPT_NOBODY enabled but not CURLOPT_HEADER, libcurl wouldn't do TYPE
  before it does SIZE which makes it less useful. I walked over the code and
+3 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ Curl and libcurl 7.17.1

 Public curl release number:               102
 Releases counted from the very beginning: 128
 Available command line options:           119
 Available command line options:           120
 Available curl_easy_setopt() options:     143
 Number of public functions in libcurl:    55
 Amount of public web site mirrors:        42
@@ -14,6 +14,7 @@ This release includes the following changes:
 o automatically append ";type=<a|i>" when using HTTP proxies for FTP urls
 o improved NSS support
 o added --proxy-negotiate
 o added --post301 and CURLOPT_POST301

This release includes the following bugfixes:

@@ -42,6 +43,6 @@ This release would not have looked like this without help, code, reports and
advice from friends like these:

 Dan Fandrich, Michal Marek, Gnter Knauf, Rob Crittenden, Immanuel Gregoire,
 Mark Davies, Max Katsev
 Mark Davies, Max Katsev, Philip Langdale
 
        Thanks! (and sorry if I forgot to mention someone)
+3 −0
Original line number Diff line number Diff line
@@ -1124,6 +1124,9 @@ typedef enum {
  CINIT(NEW_FILE_PERMS, LONG, 159),
  CINIT(NEW_DIRECTORY_PERMS, LONG, 160),

  /* Obey RFC 2616/10.3.2 and keep POSTs as POSTs after a 301 */
  CINIT(POST301, LONG, 161),

  CURLOPT_LASTENTRY /* the last unused */
} CURLoption;

+6 −3
Original line number Diff line number Diff line
@@ -2257,10 +2257,13 @@ CURLcode Curl_follow(struct SessionHandle *data,
     * violation, many webservers expect this misbehavior. So these servers
     * often answers to a POST request with an error page.  To be sure that
     * libcurl gets the page that most user agents would get, libcurl has to
     * force GET:
     * force GET.
     *
     * This behaviour can be overriden with CURLOPT_POST301.
     */
    if( data->set.httpreq == HTTPREQ_POST
        || data->set.httpreq == HTTPREQ_POST_FORM) {
    if( (data->set.httpreq == HTTPREQ_POST
         || data->set.httpreq == HTTPREQ_POST_FORM)
        && !data->set.post301) {
      infof(data,
            "Violate RFC 2616/10.3.2 and switch from POST to GET\n");
      data->set.httpreq = HTTPREQ_GET;
+7 −0
Original line number Diff line number Diff line
@@ -924,6 +924,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
    data->set.maxredirs = va_arg(param, long);
    break;

  case CURLOPT_POST301:
    /*
     * Obey RFC 2616/10.3.2 and resubmit a POST as a POST after a 301.
     */
    data->set.post301 = (bool)(0 != va_arg(param, long));
    break;

  case CURLOPT_POST:
    /* Does this option serve a purpose anymore? Yes it does, when
       CURLOPT_POSTFIELDS isn't used and the POST data is read off the
Loading