(redirect_handler): PROPFIND is defined to be "safe and
authorDan Winship <danw@src.gnome.org>
Thu, 28 Feb 2008 17:14:45 +0000 (17:14 +0000)
committerDan Winship <danw@src.gnome.org>
Thu, 28 Feb 2008 17:14:45 +0000 (17:14 +0000)
idempotent", so allow automatic redirects of it. (Pointed out by
Christian Kellner. FIXME: need a way for apps to declare
additional safe methods). Also, treat 302 like 307, not like 303,
because that behavior is universal in the real world, despite the
spec's protests.

* tests/redirect-test.c (tests): update POST 302 behavior check

* tests/Makefile.am (TESTS): oops, add redirect-test so it gets
run by "make check"/"make distcheck"

svn path=/trunk/; revision=1101

ChangeLog
libsoup/soup-session.c
tests/Makefile.am
tests/redirect-test.c

index df55d82..ead8f8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,17 @@
 
        * libsoup/soup-session.c (finalize): free priv->user_agent.
        #518798, Wouter Cloetens.
+       (redirect_handler): PROPFIND is defined to be "safe and
+       idempotent", so allow automatic redirects of it. (Pointed out by
+       Christian Kellner. FIXME: need a way for apps to declare
+       additional safe methods). Also, treat 302 like 307, not like 303,
+       because that behavior is universal in the real world, despite the
+       spec's protests.
+
+       * tests/redirect-test.c (tests): update POST 302 behavior check
+
+       * tests/Makefile.am (TESTS): oops, add redirect-test so it gets
+       run by "make check"/"make distcheck"
 
        * tests/ssl-test.c: Re-revert the change from 2008-02-09; the
        problem with ssl-test.c was not that soup_gnutls_init() wasn't
index b9083fd..a676864 100644 (file)
@@ -647,14 +647,15 @@ redirect_handler (SoupMessage *msg, gpointer user_data)
        g_return_if_fail (new_loc != NULL);
 
        if (msg->status_code == SOUP_STATUS_MOVED_PERMANENTLY ||
-           msg->status_code == SOUP_STATUS_FOUND ||
            msg->status_code == SOUP_STATUS_TEMPORARY_REDIRECT) {
                /* Don't redirect non-safe methods */
                if (msg->method != SOUP_METHOD_GET &&
                    msg->method != SOUP_METHOD_HEAD &&
-                   msg->method != SOUP_METHOD_OPTIONS)
+                   msg->method != SOUP_METHOD_OPTIONS &&
+                   msg->method != SOUP_METHOD_PROPFIND)
                        return;
-       } else if (msg->status_code == SOUP_STATUS_SEE_OTHER) {
+       } else if (msg->status_code == SOUP_STATUS_SEE_OTHER ||
+                  msg->status_code == SOUP_STATUS_FOUND) {
                /* Redirect using a GET */
                g_object_set (msg,
                              SOUP_MESSAGE_METHOD, SOUP_METHOD_GET,
index 1850a75..47f8317 100644 (file)
@@ -67,8 +67,9 @@ TESTS =                       \
        continue-test   \
        date            \
        header-parsing  \
-       uri-parsing     \
        ntlm-test       \
+       redirect-test   \
+       uri-parsing     \
        $(APACHE_TESTS) \
        $(CURL_TESTS)   \
        $(SSL_TESTS)    \
index 6507c5f..9d6985e 100644 (file)
@@ -59,11 +59,12 @@ struct {
            { "GET", "/302", 302 },
            { "GET", "/", 200 } } },
 
-       /* POST should only automatically redirect on 303 */
+       /* POST should only automatically redirect on 302 and 303 */
 
        { { { "POST", "/301", 301 },
            { NULL } } },
        { { { "POST", "/302", 302 },
+           { "GET", "/", 200 },
            { NULL } } },
        { { { "POST", "/303", 303 },
            { "GET", "/", 200 },