]> granicus.if.org Git - curl/commitdiff
bettersupport for HTTP return codes 300-399
authorDaniel Stenberg <daniel@haxx.se>
Sat, 27 Jan 2001 20:31:51 +0000 (20:31 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 27 Jan 2001 20:31:51 +0000 (20:31 +0000)
lib/transfer.c

index c6504059cc8af81c6e2291599dcec8b1b7ab095f..0099297dc680eac6b28ac56222c8fe0f9194a7c8 100644 (file)
@@ -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;
       }