summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2021-06-02 12:43:45 +0200
committerJens Georg <mail@jensge.org>2021-07-26 22:12:40 +0200
commit3a3b3492844ab7cd9e5349cad4a4b89377a4613d (patch)
tree62284a33fd6cd1bf116b3b94c7c2da5e2404ce8c
parent91f5c741ac9ff026df16111833719ce2e07ef11a (diff)
downloadgupnp-1.2.tar.gz
context: Use SoupURI instead of GUrigupnp-1.2
Do not bump the implicit requirement to GLib 2.66 for this version
-rw-r--r--libgupnp/gupnp-context.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 44e67e5..73b75be 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -1721,26 +1721,22 @@ validate_host_header (const char *host_header,
// [] from v6 addresses, splitting of the port etc.
char *uri_from_host = g_strconcat ("http://", host_header, NULL);
- char *host = NULL;
+ const char *host = NULL;
int port = 0;
- GError *error = NULL;
- g_uri_split_network (uri_from_host,
- G_URI_FLAGS_NONE,
- NULL,
- &host,
- &port,
- &error);
-
- if (error != NULL) {
- g_debug ("Failed to parse HOST header from request: %s",
- error->message);
+ SoupURI *uri = soup_uri_new (uri_from_host);
+ if (uri == NULL) {
+ g_debug ("Failed to parse HOST header %s from request",
+ host_header);
goto out;
}
+ host = soup_uri_get_host (uri);
+ port = soup_uri_get_port (uri);
+
// -1 means there was no :port; according to UDA this is allowed and
// defaults to 80, the HTTP port then
- if (port == -1) {
+ if (soup_uri_uses_default_port (uri)) {
port = 80;
}
@@ -1761,8 +1757,7 @@ validate_host_header (const char *host_header,
retval = g_str_equal (host, host_ip) && port == context_port;
out:
- g_clear_error (&error);
- g_free (host);
+ g_clear_pointer (&uri, soup_uri_free);
g_free (uri_from_host);
return retval;