** Now --adjust-extension does not modify the file extension if the file ends
in .htm.
+
+** Support HTTP/1.1 307 redirects keep request method.
\f
* Changes in Wget 1.12
+2010-11-20 Filipe Brandenburger <filbranden@gmail.com> (tiny change)
+
+ * http.c (gethttp): Repeat a POST request on a 307 response.
+ * retr.c (retrieve_url): Use NEWLOCATION_KEEP_POST.
+ * wget.h: Define NEWLOCATION_KEEP_POST.
+
2011-03-02 Tomasz Buchert <tomek.buchert@gmail.com> (tiny change)
* http.c (ensure_extension): Do not adjust the extension if the file
CLOSE_INVALIDATE (sock);
xfree_null (type);
xfree (head);
+ /* From RFC2616: The status codes 303 and 307 have
+ been added for servers that wish to make unambiguously
+ clear which kind of reaction is expected of the client.
+
+ A 307 should be redirected using the same method,
+ in other words, a POST should be preserved and not
+ converted to a GET in that case. */
+ if (statcode == HTTP_STATUS_TEMPORARY_REDIRECT)
+ return NEWLOCATION_KEEP_POST;
return NEWLOCATION;
}
}
ret = err;
goto exit;
case NEWLOCATION:
+ case NEWLOCATION_KEEP_POST:
/* Return the new location to the caller. */
if (!*newloc)
{
}
else
{
- ret = NEWLOCATION;
+ ret = err;
}
goto exit;
case RETRUNNEEDED:
proxy_url = NULL;
}
- location_changed = (result == NEWLOCATION);
+ location_changed = (result == NEWLOCATION || result == NEWLOCATION_KEEP_POST);
if (location_changed)
{
char *construced_newloc;
}
u = newloc_parsed;
- /* If we're being redirected from POST, we don't want to POST
+ /* If we're being redirected from POST, and we received a
+ redirect code different than 307, we don't want to POST
again. Many requests answer POST with a redirection to an
index page; that redirection is clearly a GET. We "suspend"
POST data for the duration of the redirections, and restore
- it when we're done. */
- if (!post_data_suspended)
+ it when we're done.
+
+ RFC2616 HTTP/1.1 introduces code 307 Temporary Redirect
+ specifically to preserve the method of the request.
+ */
+ if (result != NEWLOCATION_KEEP_POST && !post_data_suspended)
SUSPEND_POST_DATA;
goto redirected;
PROXERR,
/* 50 */
AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, VERIFCERTERR,
- UNLINKERR
+ UNLINKERR, NEWLOCATION_KEEP_POST
} uerr_t;
/* 2005-02-19 SMS.