diff options
author | Dan Winship <danw@gnome.org> | 2013-05-25 10:31:12 -0300 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-05-25 10:31:12 -0300 |
commit | 756417e57a216cffbecd09d2f67469b6b3a501e2 (patch) | |
tree | fa590d0001e146f6e4f95baba8acf27a273e4e37 /libsoup/soup-message-server-io.c | |
parent | 1e48dc8f9a8a90e8e644ce78882c9468ca1d298b (diff) | |
download | libsoup-badconnect.tar.gz |
wipbadconnect
Diffstat (limited to 'libsoup/soup-message-server-io.c')
-rw-r--r-- | libsoup/soup-message-server-io.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libsoup/soup-message-server-io.c b/libsoup/soup-message-server-io.c index e85896b3..1a148b08 100644 --- a/libsoup/soup-message-server-io.c +++ b/libsoup/soup-message-server-io.c @@ -9,6 +9,7 @@ #include "config.h" #endif +#include <stdlib.h> #include <string.h> #include <glib/gi18n-lib.h> @@ -17,6 +18,28 @@ #include "soup-message-private.h" #include "soup-misc-private.h" +static SoupURI * +parse_connect_authority (const char *req_path) +{ + SoupURI *uri; + char *fake_uri; + + fake_uri = g_strdup_printf ("https://%s", req_path); + uri = soup_uri_new (fake_uri); + g_free (fake_uri); + + if (uri->user || uri->password || + uri->query || uri->fragment || + !uri->host || + (uri->port == 0) || + (strcmp (uri->path, "/") != 0)) { + soup_uri_free (uri); + return NULL; + } + + return uri; +} + static guint parse_request_headers (SoupMessage *msg, char *headers, guint headers_len, SoupEncoding *encoding, gpointer sock, GError **error) @@ -73,8 +96,11 @@ parse_request_headers (SoupMessage *msg, char *headers, guint headers_len, if (uri) soup_uri_set_path (uri, "*"); g_free (url); + } else if (msg->method == SOUP_METHOD_CONNECT) { + /* Authority */ + uri = parse_connect_authority (req_path); } else if (*req_path != '/') { - /* Must be an absolute URI */ + /* Absolute URI */ uri = soup_uri_new (req_path); } else if (req_host) { url = g_strdup_printf ("%s://%s%s", |