summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-11-17 11:36:00 -0500
committerDan Winship <danw@gnome.org>2012-11-17 11:37:23 -0500
commitd51d1d2b513439798024cf9474a2ed4f00f4c2d3 (patch)
treef49f4d4be95ac24d36dce5e0145e29315746e5ae /tests
parent2d58084816390a61d384bfc150e5383dabdf7448 (diff)
downloadlibsoup-d51d1d2b513439798024cf9474a2ed4f00f4c2d3.tar.gz
libsoup-d51d1d2b513439798024cf9474a2ed4f00f4c2d3.tar.bz2
libsoup-d51d1d2b513439798024cf9474a2ed4f00f4c2d3.zip
SoupLogger: fix printing of Host header with IPv6 literal
SoupLogger was misprinting Host headers with IPv6 literals (even though soup-message-client-io was sending them correctly). Fix that. Also includes an addition to misc-test to verify that the Host header received by the server is correct (which it already was, but the SoupLogger bug made me think it wasn't.)
Diffstat (limited to 'tests')
-rw-r--r--tests/misc-test.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 19e9ba09..b564f269 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -1088,6 +1088,34 @@ do_dot_dot_test (void)
}
static void
+ipv6_server_callback (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *context, gpointer data)
+{
+ const char *host;
+ char expected_host[128];
+
+ host = soup_message_headers_get_one (msg->request_headers, "Host");
+ if (!host) {
+ debug_printf (1, " request has no Host header!\n");
+ errors++;
+ soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
+ return;
+ }
+
+ g_snprintf (expected_host, sizeof (expected_host),
+ "[::1]:%d", soup_server_get_port (server));
+
+ if (strcmp (host, expected_host) == 0)
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+ else {
+ debug_printf (1, " request has incorrect Host header '%s'\n", host);
+ errors++;
+ soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
+ }
+}
+
+static void
do_ipv6_test (void)
{
SoupServer *ipv6_server;
@@ -1103,7 +1131,7 @@ do_ipv6_test (void)
ipv6_server = soup_server_new (SOUP_SERVER_INTERFACE, ipv6_addr,
NULL);
g_object_unref (ipv6_addr);
- soup_server_add_handler (ipv6_server, NULL, server_callback, NULL, NULL);
+ soup_server_add_handler (ipv6_server, NULL, ipv6_server_callback, NULL, NULL);
soup_server_run_async (ipv6_server);
ipv6_uri = soup_uri_new ("http://[::1]/");