mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Support HTTP/1.1 307 redirects keep request method.
This commit is contained in:
parent
bb6a72caea
commit
e219e587b3
2
NEWS
2
NEWS
@ -57,6 +57,8 @@ Please send GNU Wget bug reports to <bug-wget@gnu.org>.
|
|||||||
|
|
||||||
** Now --adjust-extension does not modify the file extension if the file ends
|
** Now --adjust-extension does not modify the file extension if the file ends
|
||||||
in .htm.
|
in .htm.
|
||||||
|
|
||||||
|
** Support HTTP/1.1 307 redirects keep request method.
|
||||||
|
|
||||||
* Changes in Wget 1.12
|
* Changes in Wget 1.12
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
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)
|
2011-03-02 Tomasz Buchert <tomek.buchert@gmail.com> (tiny change)
|
||||||
|
|
||||||
* http.c (ensure_extension): Do not adjust the extension if the file
|
* http.c (ensure_extension): Do not adjust the extension if the file
|
||||||
|
12
src/http.c
12
src/http.c
@ -2323,6 +2323,15 @@ read_header:
|
|||||||
CLOSE_INVALIDATE (sock);
|
CLOSE_INVALIDATE (sock);
|
||||||
xfree_null (type);
|
xfree_null (type);
|
||||||
xfree (head);
|
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;
|
return NEWLOCATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2790,6 +2799,7 @@ Spider mode enabled. Check if remote file exists.\n"));
|
|||||||
ret = err;
|
ret = err;
|
||||||
goto exit;
|
goto exit;
|
||||||
case NEWLOCATION:
|
case NEWLOCATION:
|
||||||
|
case NEWLOCATION_KEEP_POST:
|
||||||
/* Return the new location to the caller. */
|
/* Return the new location to the caller. */
|
||||||
if (!*newloc)
|
if (!*newloc)
|
||||||
{
|
{
|
||||||
@ -2800,7 +2810,7 @@ Spider mode enabled. Check if remote file exists.\n"));
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = NEWLOCATION;
|
ret = err;
|
||||||
}
|
}
|
||||||
goto exit;
|
goto exit;
|
||||||
case RETRUNNEEDED:
|
case RETRUNNEEDED:
|
||||||
|
13
src/retr.c
13
src/retr.c
@ -764,7 +764,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
|||||||
proxy_url = NULL;
|
proxy_url = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
location_changed = (result == NEWLOCATION);
|
location_changed = (result == NEWLOCATION || result == NEWLOCATION_KEEP_POST);
|
||||||
if (location_changed)
|
if (location_changed)
|
||||||
{
|
{
|
||||||
char *construced_newloc;
|
char *construced_newloc;
|
||||||
@ -838,12 +838,17 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
|||||||
}
|
}
|
||||||
u = newloc_parsed;
|
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
|
again. Many requests answer POST with a redirection to an
|
||||||
index page; that redirection is clearly a GET. We "suspend"
|
index page; that redirection is clearly a GET. We "suspend"
|
||||||
POST data for the duration of the redirections, and restore
|
POST data for the duration of the redirections, and restore
|
||||||
it when we're done. */
|
it when we're done.
|
||||||
if (!post_data_suspended)
|
|
||||||
|
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;
|
SUSPEND_POST_DATA;
|
||||||
|
|
||||||
goto redirected;
|
goto redirected;
|
||||||
|
@ -353,7 +353,7 @@ typedef enum
|
|||||||
PROXERR,
|
PROXERR,
|
||||||
/* 50 */
|
/* 50 */
|
||||||
AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, VERIFCERTERR,
|
AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, VERIFCERTERR,
|
||||||
UNLINKERR
|
UNLINKERR, NEWLOCATION_KEEP_POST
|
||||||
} uerr_t;
|
} uerr_t;
|
||||||
|
|
||||||
/* 2005-02-19 SMS.
|
/* 2005-02-19 SMS.
|
||||||
|
Loading…
Reference in New Issue
Block a user