diff options
-rw-r--r-- | lib/transfer.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index c6504059c..0099297dc 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -725,13 +725,48 @@ CURLcode curl_transfer(CURL *curl) data->newurl = NULL; /* don't show! */ data->bits.urlstringalloc = TRUE; /* the URL is allocated */ - /* Disable both types of POSTs, since doing a second POST when - following isn't what anyone would want! */ - data->bits.http_post = FALSE; - data->bits.http_formpost = FALSE; - infof(data, "Follows Location: to new URL: '%s'\n", data->url); + /* + * We get here when the HTTP code is 300-399. We need to perform + * differently based on exactly what return code there was. + * Discussed on the curl mailing list and posted about on the 26th + * of January 2001. + */ + switch(data->progress.httpcode) { + case 300: /* Multiple Choices */ + case 301: /* Moved Permanently */ + case 302: /* Found */ + case 306: /* Not used */ + case 307: /* Temporary Redirect */ + default: /* for all unknown ones */ + /* These are explicitly mention since I've checked RFC2616 and they + * seem to be OK to POST to. + */ + break; + case 303: /* See Other */ + /* Disable both types of POSTs, since doing a second POST when + * following isn't what anyone would want! */ + data->bits.http_post = FALSE; + data->bits.http_formpost = FALSE; + data->httpreq = HTTPREQ_GET; /* enfore GET request */ + infof(data, "Disables POST\n"); + break; + case 304: /* Not Modified */ + /* 304 means we did a conditional request and it was "Not modified". + * We shouldn't get any Location: header in this response! + */ + break; + case 305: /* Use Proxy */ + /* (quote from RFC2616, section 10.3.6): + * "The requested resource MUST be accessed through the proxy given + * by the Location field. The Location field gives the URI of the + * proxy. The recipient is expected to repeat this single request + * via the proxy. 305 responses MUST only be generated by origin + * servers." + */ + break; + } curl_disconnect(c_connect); continue; } |