Fix POST 301 redirect behavior
authorDan Winship <danw@gnome.org>
Mon, 22 Jun 2009 21:52:39 +0000 (17:52 -0400)
committerDan Winship <danw@gnome.org>
Mon, 22 Jun 2009 21:52:39 +0000 (17:52 -0400)
We were doing POST->GET translation on 302 and 303, but we need to do
it on 301 as well to be compatible.

http://bugzilla.gnome.org/show_bug.cgi?id=586692

libsoup/soup-session.c
tests/redirect-test.c

index b9b74f7..3c824d5 100644 (file)
@@ -845,7 +845,9 @@ redirect_handler (SoupMessage *msg, gpointer user_data)
 
        if (msg->status_code == SOUP_STATUS_SEE_OTHER ||
            (msg->status_code == SOUP_STATUS_FOUND &&
-            !SOUP_METHOD_IS_SAFE (msg->method))) {
+            !SOUP_METHOD_IS_SAFE (msg->method)) ||
+           (msg->status_code == SOUP_STATUS_MOVED_PERMANENTLY &&
+            msg->method == SOUP_METHOD_POST)) {
                /* Redirect using a GET */
                g_object_set (msg,
                              SOUP_MESSAGE_METHOD, SOUP_METHOD_GET,
index 9d5d9b8..9e21bd1 100644 (file)
@@ -82,9 +82,10 @@ static struct {
            { "HEAD", "/302", 302 },
            { "HEAD", "/", 200 } } },
 
-       /* POST should only automatically redirect on 302 and 303 */
+       /* POST should only automatically redirect on 301, 302 and 303 */
 
        { { { "POST", "/301", 301 },
+           { "GET", "/", 200 },
            { NULL } } },
        { { { "POST", "/302", 302 },
            { "GET", "/", 200 },