diff options
author | Dan Winship <danw@gnome.org> | 2011-08-08 17:48:13 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-08-08 17:48:13 -0400 |
commit | 6b2b958f588526fac12ccf8b73d14afd2195957f (patch) | |
tree | 8da9e2cb7aab6d6f48d8615e5b1050626ca02c84 /tests | |
parent | 5ddafe9abc8b594016f401c0b53a481e706e74c6 (diff) | |
download | libsoup-6b2b958f588526fac12ccf8b73d14afd2195957f.tar.gz libsoup-6b2b958f588526fac12ccf8b73d14afd2195957f.tar.bz2 libsoup-6b2b958f588526fac12ccf8b73d14afd2195957f.zip |
Call soup_message_clean_response() when restarting a message
When a message got restarted, we were leaving the previous response
state in the message, which is bad for various reasons.
In particular, this caused a problem with non-keepalive redirections
of https URLs through proxies (!), because after the second CONNECT
succeeded, it would see that the message already had a status_code
set, and so it thought the message had been cancelled or something
while it was processing the CONNECT. proxy-test now has a regression
test for this case.
Based on patches and analysis from DongJae Kim and Thierry Reding.
https://bugzilla.gnome.org/show_bug.cgi?id=631368
Diffstat (limited to 'tests')
-rw-r--r-- | tests/httpd.conf.in | 2 | ||||
-rw-r--r-- | tests/proxy-test.c | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/tests/httpd.conf.in b/tests/httpd.conf.in index 848031ec..de0b75fa 100644 --- a/tests/httpd.conf.in +++ b/tests/httpd.conf.in @@ -31,7 +31,7 @@ LoadModule ssl_module @APACHE_SSL_MODULE_DIR@/mod_ssl.so DirectoryIndex index.txt TypesConfig /dev/null AddType application/x-httpd-php .php - +Redirect permanent /redirected /index.txt # Proxy #1: unauthenticated Listen 127.0.0.1:47526 diff --git a/tests/proxy-test.c b/tests/proxy-test.c index 014da394..27d8d2e6 100644 --- a/tests/proxy-test.c +++ b/tests/proxy-test.c @@ -200,6 +200,45 @@ do_proxy_fragment_test (SoupURI *base_uri) soup_test_session_abort_unref (session); } +static void +do_proxy_redirect_test (void) +{ + SoupSession *session; + SoupURI *proxy_uri, *req_uri, *new_uri; + SoupMessage *msg; + + debug_printf (1, "\nTesting redirection through proxy\n"); + + proxy_uri = soup_uri_new (proxies[SIMPLE_PROXY]); + session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, + SOUP_SESSION_PROXY_URI, proxy_uri, + NULL); + soup_uri_free (proxy_uri); + + req_uri = soup_uri_new (HTTPS_SERVER); + soup_uri_set_path (req_uri, "/redirected"); + msg = soup_message_new_from_uri (SOUP_METHOD_GET, req_uri); + soup_message_headers_append (msg->request_headers, + "Connection", "close"); + soup_session_send_message (session, msg); + + new_uri = soup_message_get_uri (msg); + if (!strcmp (req_uri->path, new_uri->path)) { + debug_printf (1, " message was not redirected!\n"); + errors++; + } + soup_uri_free (req_uri); + + if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { + debug_printf (1, " unexpected status %d %s!\n", + msg->status_code, msg->reason_phrase); + errors++; + } + + g_object_unref (msg); + soup_test_session_abort_unref (session); +} + int main (int argc, char **argv) { @@ -221,6 +260,7 @@ main (int argc, char **argv) soup_uri_set_port (base_uri, soup_server_get_port (server)); do_proxy_fragment_test (base_uri); + do_proxy_redirect_test (); soup_uri_free (base_uri); soup_test_server_quit_unref (server); |