summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-06-08 15:13:20 -0400
committerDan Winship <danw@gnome.org>2015-03-01 10:36:27 -0500
commit9e8b1f769783991f388200f32a66dbe2722f2912 (patch)
tree239ea941a89e095eb2a720255c9e56a2111639e8
parent14a1d3158f1136e2a146601d317bb4a5dddbb9dd (diff)
downloadlibsoup-9e8b1f769783991f388200f32a66dbe2722f2912.tar.gz
soup-message-server-io: handle "CONNECT" syntax when parsing requests
-rw-r--r--libsoup/soup-message-server-io.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/libsoup/soup-message-server-io.c b/libsoup/soup-message-server-io.c
index 683a4ee3..35b544c2 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>
@@ -18,6 +19,28 @@
#include "soup-misc-private.h"
#include "soup-socket-private.h"
+static SoupURI *
+parse_connect_authority (const char *req_path)
+{
+ SoupURI *uri;
+ char *fake_uri;
+
+ fake_uri = g_strdup_printf ("http://%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)
@@ -74,8 +97,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",