summaryrefslogtreecommitdiff
path: root/tests/proxy-test.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2010-04-10 12:00:58 -0400
committerDan Winship <danw@gnome.org>2010-04-10 12:16:58 -0400
commit0df6a4c66879f64bdf3ba57358e8b97c586b2387 (patch)
tree454bf7717e110ada8c602fbaf8fe426a7cacbbad /tests/proxy-test.c
parent26c6cd984ad229a4c1d3c00889956dc0cbf53877 (diff)
downloadlibsoup-0df6a4c66879f64bdf3ba57358e8b97c586b2387.tar.gz
Fix for proxies that close the connection when 407'ing a CONNECT
If we try to CONNECT through a proxy, and it returns a "407 Proxy Authentication Required" but then closes the connection, we have to create a new connection before we can try CONNECTing again. The old soup-connection.c tunnel code did this, but it got accidentally lost in the soup-session.c version. Fix up tests/proxy-test to test both the connection-close and the persistent-connection cases. This was the underlying bug in https://bugzilla.gnome.org/show_bug.cgi?id=611663, and is at least part of https://bugzilla.gnome.org/show_bug.cgi?id=611539.
Diffstat (limited to 'tests/proxy-test.c')
-rw-r--r--tests/proxy-test.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/tests/proxy-test.c b/tests/proxy-test.c
index d0c348e5..d23e7d17 100644
--- a/tests/proxy-test.c
+++ b/tests/proxy-test.c
@@ -69,13 +69,29 @@ authenticate (SoupSession *session, SoupMessage *msg,
}
static void
-test_url (const char *url, int proxy, guint expected, gboolean sync)
+set_close_on_connect (SoupSession *session, SoupMessage *msg,
+ SoupSocket *sock, gpointer user_data)
+{
+ /* This is used to test that we can handle the server closing
+ * the connection when returning a 407 in response to a
+ * CONNECT. (Rude!)
+ */
+ if (msg->method == SOUP_METHOD_CONNECT) {
+ soup_message_headers_append (msg->request_headers,
+ "Connection", "close");
+ }
+}
+
+static void
+test_url (const char *url, int proxy, guint expected,
+ gboolean sync, gboolean close)
{
SoupSession *session;
SoupURI *proxy_uri;
SoupMessage *msg;
- debug_printf (1, " GET %s via %s\n", url, proxy_names[proxy]);
+ debug_printf (1, " GET %s via %s%s\n", url, proxy_names[proxy],
+ close ? " (with Connection: close)" : "");
if (proxy == UNAUTH_PROXY && expected != SOUP_STATUS_FORBIDDEN)
expected = SOUP_STATUS_PROXY_UNAUTHORIZED;
@@ -89,6 +105,10 @@ test_url (const char *url, int proxy, guint expected, gboolean sync)
soup_uri_free (proxy_uri);
g_signal_connect (session, "authenticate",
G_CALLBACK (authenticate), NULL);
+ if (close) {
+ g_signal_connect (session, "request-started",
+ G_CALLBACK (set_close_on_connect), NULL);
+ }
msg = soup_message_new (SOUP_METHOD_GET, url);
if (!msg) {
@@ -124,17 +144,18 @@ run_test (int i, gboolean sync)
http_url = g_strconcat (HTTP_SERVER, tests[i].url, NULL);
https_url = g_strconcat (HTTPS_SERVER, tests[i].url, NULL);
}
- test_url (http_url, SIMPLE_PROXY, tests[i].final_status, sync);
+ test_url (http_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE);
#ifdef HAVE_SSL
- test_url (https_url, SIMPLE_PROXY, tests[i].final_status, sync);
+ test_url (https_url, SIMPLE_PROXY, tests[i].final_status, sync, FALSE);
#endif
- test_url (http_url, AUTH_PROXY, tests[i].final_status, sync);
+ test_url (http_url, AUTH_PROXY, tests[i].final_status, sync, FALSE);
#ifdef HAVE_SSL
- test_url (https_url, AUTH_PROXY, tests[i].final_status, sync);
+ test_url (https_url, AUTH_PROXY, tests[i].final_status, sync, FALSE);
+ test_url (https_url, AUTH_PROXY, tests[i].final_status, sync, TRUE);
#endif
- test_url (http_url, UNAUTH_PROXY, tests[i].final_status, sync);
+ test_url (http_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE);
#ifdef HAVE_SSL
- test_url (https_url, UNAUTH_PROXY, tests[i].final_status, sync);
+ test_url (https_url, UNAUTH_PROXY, tests[i].final_status, sync, FALSE);
#endif
g_free (http_url);