summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2021-02-11 10:47:09 +0100
committerCarlos Garcia Campos <cgarcia@igalia.com>2021-02-11 11:10:31 +0100
commit79a0830efce367f8175802171c58cb5209f67c9e (patch)
tree5711da41ee83aaa54c6c8b3248fe37b6dab3b8fd
parent1fa903e5d0a7e21bb2c4391ebafae15c7e217df9 (diff)
downloadlibsoup-carlosgc/no-aliases.tar.gz
Remove http and https aliases supportcarlosgc/no-aliases
It doesn't seem to be used. If needed we can just bring it back in the future.
-rw-r--r--docs/reference/client-howto.xml13
-rw-r--r--docs/reference/server-howto.xml11
-rw-r--r--libsoup/auth/soup-auth-negotiate.c2
-rw-r--r--libsoup/cookies/soup-cookie-jar.c4
-rw-r--r--libsoup/cookies/soup-cookie.c2
-rw-r--r--libsoup/hsts/soup-hsts-enforcer.c4
-rw-r--r--libsoup/server/soup-server.c98
-rw-r--r--libsoup/soup-session.c113
-rw-r--r--libsoup/soup-uri-utils-private.h6
-rw-r--r--libsoup/soup-uri-utils.c40
-rw-r--r--tests/hsts-db-test.c4
-rw-r--r--tests/hsts-test.c4
-rw-r--r--tests/misc-test.c99
-rw-r--r--tests/server-test.c104
-rw-r--r--tests/timeout-test.c4
15 files changed, 37 insertions, 471 deletions
diff --git a/docs/reference/client-howto.xml b/docs/reference/client-howto.xml
index d9c558ae..898cfaf1 100644
--- a/docs/reference/client-howto.xml
+++ b/docs/reference/client-howto.xml
@@ -78,19 +78,6 @@ you can specify various additional options:
</para></listitem>
</varlistentry>
<varlistentry>
- <term><link linkend="SoupSession:http-aliases"><literal>"http-aliases"</literal></link>
- and <link linkend="SoupSession:https-aliases"><literal>"https-aliases"</literal></link></term>
- <listitem><para>
- Allow you to tell the session to recognize additional URI
- schemes as aliases for "<literal>http</literal>" or
- <literal>https</literal>. You can set this if you are
- using URIs with schemes like "<literal>dav</literal>" or
- "<literal>webcal</literal>" (and in particular, you need
- to set this if the server you are talking to might return
- redirects with such a scheme).
- </para></listitem>
- </varlistentry>
- <varlistentry>
<term><link linkend="SoupSession:proxy-resolver"><literal>"proxy-resolver"</literal></link></term>
<listitem>
<para>
diff --git a/docs/reference/server-howto.xml b/docs/reference/server-howto.xml
index 0d6545fd..7f743e4f 100644
--- a/docs/reference/server-howto.xml
+++ b/docs/reference/server-howto.xml
@@ -55,17 +55,6 @@ a few additional options:
on all responses.
</para></listitem>
</varlistentry>
- <varlistentry>
- <term><link linkend="SoupServer:http-aliases"><literal>"http-aliases"</literal></link>
- and <link linkend="SoupServer:https-aliases"><literal>"https-aliases"</literal></link></term>
- <listitem><para>
- Allow you to tell the server to recognize additional URI
- schemes as aliases for "<literal>http</literal>" or
- <literal>https</literal>. You can set this if you are
- serving URIs with schemes like "<literal>dav</literal>" or
- "<literal>webcal</literal>".
- </para></listitem>
- </varlistentry>
</variablelist>
</refsect2>
diff --git a/libsoup/auth/soup-auth-negotiate.c b/libsoup/auth/soup-auth-negotiate.c
index 34c4830b..dea5141c 100644
--- a/libsoup/auth/soup-auth-negotiate.c
+++ b/libsoup/auth/soup-auth-negotiate.c
@@ -462,7 +462,7 @@ check_auth_trusted_uri (SoupConnectionAuth *auth, SoupMessage *msg)
/* If no trusted URIs are set, we allow all HTTPS URIs */
if (!trusted_uris)
- return soup_uri_is_https (msg_uri, NULL);
+ return soup_uri_is_https (msg_uri);
matched = g_slist_find_custom (trusted_uris,
msg_uri,
diff --git a/libsoup/cookies/soup-cookie-jar.c b/libsoup/cookies/soup-cookie-jar.c
index 0afdcb79..b27c779f 100644
--- a/libsoup/cookies/soup-cookie-jar.c
+++ b/libsoup/cookies/soup-cookie-jar.c
@@ -597,7 +597,7 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, GUri *u
}
/* Cannot set a secure cookie over http */
- if (uri != NULL && !soup_uri_is_https (uri, NULL) && soup_cookie_get_secure (cookie)) {
+ if (uri != NULL && !soup_uri_is_https (uri) && soup_cookie_get_secure (cookie)) {
soup_cookie_free (cookie);
return;
}
@@ -607,7 +607,7 @@ soup_cookie_jar_add_cookie_full (SoupCookieJar *jar, SoupCookie *cookie, GUri *u
old_cookie = oc->data;
if (!strcmp (soup_cookie_get_name (cookie), soup_cookie_get_name (old_cookie)) &&
!g_strcmp0 (soup_cookie_get_path (cookie), soup_cookie_get_path (old_cookie))) {
- if (soup_cookie_get_secure (oc->data) && uri != NULL && !soup_uri_is_https (uri, NULL)) {
+ if (soup_cookie_get_secure (oc->data) && uri != NULL && !soup_uri_is_https (uri)) {
/* We do not allow overwriting secure cookies from an insecure origin
* https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-01
*/
diff --git a/libsoup/cookies/soup-cookie.c b/libsoup/cookies/soup-cookie.c
index 19936dc4..5d3e9444 100644
--- a/libsoup/cookies/soup-cookie.c
+++ b/libsoup/cookies/soup-cookie.c
@@ -1099,7 +1099,7 @@ soup_cookie_applies_to_uri (SoupCookie *cookie, GUri *uri)
g_return_val_if_fail (SOUP_URI_IS_VALID (uri), FALSE);
- if (cookie->secure && !soup_uri_is_https (uri, NULL))
+ if (cookie->secure && !soup_uri_is_https (uri))
return FALSE;
if (cookie->expires && soup_date_time_is_past (cookie->expires))
diff --git a/libsoup/hsts/soup-hsts-enforcer.c b/libsoup/hsts/soup-hsts-enforcer.c
index 5a6090a4..95852601 100644
--- a/libsoup/hsts/soup-hsts-enforcer.c
+++ b/libsoup/hsts/soup-hsts-enforcer.c
@@ -536,7 +536,7 @@ preprocess_request (SoupHSTSEnforcer *enforcer, SoupMessage *msg)
if (g_hostname_is_ip_address (host))
return;
- if (soup_uri_is_http (uri, NULL)) {
+ if (soup_uri_is_http (uri)) {
if (g_hostname_is_ascii_encoded (host)) {
canonicalized = g_hostname_to_unicode (host);
if (!canonicalized)
@@ -550,7 +550,7 @@ preprocess_request (SoupHSTSEnforcer *enforcer, SoupMessage *msg)
g_signal_emit (enforcer, signals[HSTS_ENFORCED], 0, msg);
}
g_free (canonicalized);
- } else if (soup_uri_is_https (uri, NULL)) {
+ } else if (soup_uri_is_https (uri)) {
soup_message_add_header_handler (msg, "got-headers",
"Strict-Transport-Security",
G_CALLBACK (got_sts_header_cb),
diff --git a/libsoup/server/soup-server.c b/libsoup/server/soup-server.c
index 555a3bc1..b500de42 100644
--- a/libsoup/server/soup-server.c
+++ b/libsoup/server/soup-server.c
@@ -172,8 +172,6 @@ typedef struct {
GSList *auth_domains;
- char **http_aliases, **https_aliases;
-
GPtrArray *websocket_extension_types;
gboolean disposed;
@@ -190,8 +188,6 @@ enum {
PROP_TLS_CERTIFICATE,
PROP_RAW_PATHS,
PROP_SERVER_HEADER,
- PROP_HTTP_ALIASES,
- PROP_HTTPS_ALIASES,
LAST_PROP
};
@@ -223,10 +219,6 @@ soup_server_init (SoupServer *server)
priv->handlers = soup_path_map_new ((GDestroyNotify)free_handler);
- priv->http_aliases = g_new (char *, 2);
- priv->http_aliases[0] = g_strdup ("*");
- priv->http_aliases[1] = NULL;
-
priv->websocket_extension_types = g_ptr_array_new_with_free_func ((GDestroyNotify)g_type_class_unref);
/* Use permessage-deflate extension by default */
@@ -261,37 +253,11 @@ soup_server_finalize (GObject *object)
g_clear_pointer (&priv->loop, g_main_loop_unref);
- g_strfreev (priv->http_aliases);
- g_strfreev (priv->https_aliases);
-
g_ptr_array_free (priv->websocket_extension_types, TRUE);
G_OBJECT_CLASS (soup_server_parent_class)->finalize (object);
}
-/* priv->http_aliases and priv->https_aliases are stored as lower-case strings,
- * so we can't just use g_strdupv() to set them.
- */
-static void
-set_aliases (char ***variable, char **value)
-{
- int len, i;
-
- if (*variable)
- g_strfreev (*variable);
-
- if (!value) {
- *variable = NULL;
- return;
- }
-
- len = g_strv_length (value);
- *variable = g_new (char *, len + 1);
- for (i = 0; i < len; i++)
- (*variable)[i] = g_ascii_strdown (value[i], -1);
- (*variable)[i] = NULL;
-}
-
static void
soup_server_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
@@ -324,12 +290,6 @@ soup_server_set_property (GObject *object, guint prop_id,
} else
priv->server_header = g_strdup (header);
break;
- case PROP_HTTP_ALIASES:
- set_aliases (&priv->http_aliases, g_value_get_boxed (value));
- break;
- case PROP_HTTPS_ALIASES:
- set_aliases (&priv->https_aliases, g_value_get_boxed (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -353,12 +313,6 @@ soup_server_get_property (GObject *object, guint prop_id,
case PROP_SERVER_HEADER:
g_value_set_string (value, priv->server_header);
break;
- case PROP_HTTP_ALIASES:
- g_value_set_boxed (value, priv->http_aliases);
- break;
- case PROP_HTTPS_ALIASES:
- g_value_set_boxed (value, priv->https_aliases);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -537,54 +491,6 @@ soup_server_class_init (SoupServerClass *server_class)
"Server header",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
-
- /**
- * SoupServer:http-aliases:
- *
- * A %NULL-terminated array of URI schemes that should be
- * considered to be aliases for "http". Eg, if this included
- * <literal>"dav"</literal>, than a URI of
- * <literal>dav://example.com/path</literal> would be treated
- * identically to <literal>http://example.com/path</literal>.
- * In particular, this is needed in cases where a client
- * sends requests with absolute URIs, where those URIs do
- * not use "http:".
- *
- * The default value is an array containing the single element
- * <literal>"*"</literal>, a special value which means that
- * any scheme except "https" is considered to be an alias for
- * SoupServer:http.
- *
- * See also #SoupServer:https-aliases.
- *
- * Since: 2.44
- */
- g_object_class_install_property (
- object_class, PROP_HTTP_ALIASES,
- g_param_spec_boxed ("http-aliases",
- "http aliases",
- "URI schemes that are considered aliases for 'http'",
- G_TYPE_STRV,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- /**
- * SoupServer:https-aliases:
- *
- * A comma-delimited list of URI schemes that should be
- * considered to be aliases for "https". See
- * #SoupServer:http-aliases for more information.
- *
- * The default value is %NULL, meaning that no URI schemes
- * are considered aliases for "https".
- *
- * Since: 2.44
- */
- g_object_class_install_property (
- object_class, PROP_HTTPS_ALIASES,
- g_param_spec_boxed ("https-aliases",
- "https aliases",
- "URI schemes that are considered aliases for 'https'",
- G_TYPE_STRV,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -808,8 +714,8 @@ got_headers (SoupServer *server,
sock = soup_server_message_get_soup_socket (msg);
uri = soup_server_message_get_uri (msg);
- if ((soup_socket_is_ssl (sock) && !soup_uri_is_https (uri, priv->https_aliases)) ||
- (!soup_socket_is_ssl (sock) && !soup_uri_is_http (uri, priv->http_aliases))) {
+ if ((soup_socket_is_ssl (sock) && !soup_uri_is_https (uri)) ||
+ (!soup_socket_is_ssl (sock) && !soup_uri_is_http (uri))) {
soup_server_message_set_status (msg, SOUP_STATUS_BAD_REQUEST, NULL);
return;
}
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index baecb245..e37bcedb 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -132,8 +132,6 @@ typedef struct {
GCond conn_cond;
GMainContext *async_context;
-
- char **http_aliases, **https_aliases;
} SoupSessionPrivate;
static void free_host (SoupSessionHost *host);
@@ -186,8 +184,6 @@ enum {
PROP_ACCEPT_LANGUAGE,
PROP_ACCEPT_LANGUAGE_AUTO,
PROP_IDLE_TIMEOUT,
- PROP_HTTP_ALIASES,
- PROP_HTTPS_ALIASES,
PROP_LOCAL_ADDRESS,
PROP_TLS_INTERACTION,
@@ -309,9 +305,6 @@ soup_session_finalize (GObject *object)
g_clear_object (&priv->proxy_resolver);
g_clear_pointer (&priv->proxy_uri, g_uri_unref);
- g_strfreev (priv->http_aliases);
- g_strfreev (priv->https_aliases);
-
g_clear_pointer (&priv->socket_props, soup_socket_properties_unref);
G_OBJECT_CLASS (soup_session_parent_class)->finalize (object);
@@ -391,26 +384,6 @@ set_use_system_ca_file (SoupSession *session, gboolean use_system_ca_file)
g_clear_object (&system_default);
}
-/* priv->http_aliases and priv->https_aliases are normalized to be lower-case
- * so we can't just use g_strdupv() to set them.
- */
-static void
-set_aliases (char ***variable, char **value)
-{
- int len, i;
-
- g_clear_pointer (variable, g_strfreev);
-
- if (!value)
- return;
-
- len = g_strv_length (value);
- *variable = g_new (char *, len + 1);
- for (i = 0; i < len; i++)
- (*variable)[i] = g_ascii_strdown (value[i], -1);
- (*variable)[i] = NULL;
-}
-
static void
set_proxy_resolver (SoupSession *session, GUri *uri,
GProxyResolver *g_resolver)
@@ -508,12 +481,6 @@ soup_session_set_property (GObject *object, guint prop_id,
priv->idle_timeout = g_value_get_uint (value);
socket_props_changed = TRUE;
break;
- case PROP_HTTP_ALIASES:
- set_aliases (&priv->http_aliases, g_value_get_boxed (value));
- break;
- case PROP_HTTPS_ALIASES:
- set_aliases (&priv->https_aliases, g_value_get_boxed (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -584,12 +551,6 @@ soup_session_get_property (GObject *object, guint prop_id,
case PROP_IDLE_TIMEOUT:
g_value_set_uint (value, priv->idle_timeout);
break;
- case PROP_HTTP_ALIASES:
- g_value_set_boxed (value, priv->http_aliases);
- break;
- case PROP_HTTPS_ALIASES:
- g_value_set_boxed (value, priv->https_aliases);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -680,10 +641,8 @@ soup_session_host_new (SoupSession *session, GUri *uri)
host = g_slice_new0 (SoupSessionHost);
if (g_strcmp0 (scheme, "http") &&
g_strcmp0 (scheme, "https")) {
- SoupSessionPrivate *priv = soup_session_get_instance_private (session);
-
host->uri = soup_uri_copy (uri,
- SOUP_URI_SCHEME, soup_uri_is_https (uri, priv->https_aliases) ?
+ SOUP_URI_SCHEME, soup_uri_is_https (uri) ?
"https" : "http",
SOUP_URI_NONE);
} else
@@ -709,7 +668,7 @@ get_host_for_uri (SoupSession *session, GUri *uri)
gboolean https;
GUri *uri_tmp = NULL;
- https = soup_uri_is_https (uri, priv->https_aliases);
+ https = soup_uri_is_https (uri);
if (https)
host = g_hash_table_lookup (priv->https_hosts, uri);
else
@@ -717,7 +676,7 @@ get_host_for_uri (SoupSession *session, GUri *uri)
if (host)
return host;
- if (!soup_uri_is_http (uri, NULL) && !soup_uri_is_https (uri, NULL)) {
+ if (!soup_uri_is_http (uri) && !soup_uri_is_https (uri)) {
uri = uri_tmp = soup_uri_copy (uri,
SOUP_URI_SCHEME, https ? "https" : "http",
SOUP_URI_NONE);
@@ -775,7 +734,6 @@ redirection_uri (SoupSession *session,
SoupMessage *msg,
GError **error)
{
- SoupSessionPrivate *priv;
const char *new_loc;
GUri *new_uri;
@@ -793,10 +751,8 @@ redirection_uri (SoupSession *session,
if (!new_uri)
return NULL;
- priv = soup_session_get_instance_private (session);
if (!g_uri_get_host (new_uri) || !*g_uri_get_host (new_uri) ||
- (!soup_uri_is_http (new_uri, priv->http_aliases) &&
- !soup_uri_is_https (new_uri, priv->https_aliases))) {
+ (!soup_uri_is_http (new_uri) && !soup_uri_is_https (new_uri))) {
g_uri_unref (new_uri);
g_set_error (error,
SOUP_SESSION_ERROR,
@@ -1116,7 +1072,7 @@ free_unused_host (gpointer user_data)
/* This will free the host in addition to removing it from the
* hash table
*/
- if (soup_uri_is_https (uri, NULL))
+ if (soup_uri_is_https (uri))
g_hash_table_remove (priv->https_hosts, uri);
else
g_hash_table_remove (priv->http_hosts, uri);
@@ -1458,7 +1414,7 @@ get_connection_for_host (SoupSession *session,
ensure_socket_props (session);
conn = g_object_new (SOUP_TYPE_CONNECTION,
"remote-uri", host->uri,
- "ssl", soup_uri_is_https (host->uri, priv->https_aliases),
+ "ssl", soup_uri_is_https (host->uri),
"socket-properties", priv->socket_props,
NULL);
@@ -2469,51 +2425,6 @@ soup_session_class_init (SoupSessionClass *session_class)
G_PARAM_STATIC_STRINGS));
/**
- * SoupSession:http-aliases:
- *
- * A %NULL-terminated array of URI schemes that should be
- * considered to be aliases for "http". Eg, if this included
- * <literal>"dav"</literal>, than a URI of
- * <literal>dav://example.com/path</literal> would be treated
- * identically to <literal>http://example.com/path</literal>.
- *
- * In a plain #SoupSession, the default value is %NULL,
- * meaning that only "http" is recognized as meaning "http".
- *
- * See also #SoupSession:https-aliases.
- *
- * Since: 2.38
- */
- g_object_class_install_property (
- object_class, PROP_HTTP_ALIASES,
- g_param_spec_boxed ("http-aliases",
- "http aliases",
- "URI schemes that are considered aliases for 'http'",
- G_TYPE_STRV,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
- /**
- * SoupSession:https-aliases:
- *
- * A comma-delimited list of URI schemes that should be
- * considered to be aliases for "https". See
- * #SoupSession:http-aliases for more information.
- *
- * The default value is %NULL, meaning that no URI schemes
- * are considered aliases for "https".
- *
- * Since: 2.38
- */
- g_object_class_install_property (
- object_class, PROP_HTTPS_ALIASES,
- g_param_spec_boxed ("https-aliases",
- "https aliases",
- "URI schemes that are considered aliases for 'https'",
- G_TYPE_STRV,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /**
* SoupSession:local-address:
*
* Sets the #GInetSocketAddress to use for the client side of
@@ -3250,7 +3161,6 @@ soup_session_read_uri_async (SoupSession *session,
GAsyncReadyCallback callback,
gpointer user_data)
{
- SoupSessionPrivate *priv;
GTask *task;
GUri *soup_uri;
SoupMessage *msg;
@@ -3276,10 +3186,7 @@ soup_session_read_uri_async (SoupSession *session,
return;
}
- priv = soup_session_get_instance_private (session);
-
- if (!soup_uri_is_http (soup_uri, priv->http_aliases) &&
- !soup_uri_is_https (soup_uri, priv->https_aliases)) {
+ if (!soup_uri_is_http (soup_uri) && !soup_uri_is_https (soup_uri)) {
g_task_return_new_error (task,
SOUP_SESSION_ERROR,
SOUP_SESSION_ERROR_UNSUPPORTED_URI_SCHEME,
@@ -3386,7 +3293,6 @@ soup_session_read_uri (SoupSession *session,
char **content_type,
GError **error)
{
- SoupSessionPrivate *priv;
GUri *soup_uri;
SoupMessage *msg;
GInputStream *stream;
@@ -3409,10 +3315,7 @@ soup_session_read_uri (SoupSession *session,
return NULL;
}
- priv = soup_session_get_instance_private (session);
-
- if (!soup_uri_is_http (soup_uri, priv->http_aliases) &&
- !soup_uri_is_https (soup_uri, priv->https_aliases)) {
+ if (!soup_uri_is_http (soup_uri) && !soup_uri_is_https (soup_uri)) {
g_set_error (error,
SOUP_SESSION_ERROR,
SOUP_SESSION_ERROR_UNSUPPORTED_URI_SCHEME,
diff --git a/libsoup/soup-uri-utils-private.h b/libsoup/soup-uri-utils-private.h
index 6bc2b38d..3dbdb855 100644
--- a/libsoup/soup-uri-utils-private.h
+++ b/libsoup/soup-uri-utils-private.h
@@ -10,11 +10,9 @@
G_BEGIN_DECLS
-gboolean soup_uri_is_http (GUri *uri,
- char **aliases);
+gboolean soup_uri_is_http (GUri *uri);
-gboolean soup_uri_is_https (GUri *uri,
- char **aliases);
+gboolean soup_uri_is_https (GUri *uri);
gboolean soup_uri_uses_default_port (GUri *uri);
diff --git a/libsoup/soup-uri-utils.c b/libsoup/soup-uri-utils.c
index f29a5e32..8fea9a63 100644
--- a/libsoup/soup-uri-utils.c
+++ b/libsoup/soup-uri-utils.c
@@ -245,51 +245,31 @@ soup_uri_host_equal (gconstpointer v1, gconstpointer v2)
}
gboolean
-soup_uri_is_https (GUri *uri, char **aliases)
+soup_uri_is_https (GUri *uri)
{
- g_return_val_if_fail (uri != NULL, FALSE);
+ const char *scheme;
- const char *scheme = g_uri_get_scheme (uri);
+ g_assert (uri != NULL);
+ scheme = g_uri_get_scheme (uri);
if (G_UNLIKELY (scheme == NULL))
return FALSE;
- if (strcmp (scheme, "https") == 0 ||
- strcmp (scheme, "wss") == 0)
- return TRUE;
- else if (!aliases)
- return FALSE;
-
- for (int i = 0; aliases[i]; i++) {
- if (strcmp (scheme, aliases[i]) == 0)
- return TRUE;
- }
-
- return FALSE;
+ return strcmp (scheme, "https") == 0 || strcmp (scheme, "wss") == 0;
}
gboolean
-soup_uri_is_http (GUri *uri, char **aliases)
+soup_uri_is_http (GUri *uri)
{
- g_return_val_if_fail (uri != NULL, FALSE);
+ const char *scheme;
- const char *scheme = g_uri_get_scheme (uri);
+ g_assert (uri != NULL);
+ scheme = g_uri_get_scheme (uri);
if (G_UNLIKELY (scheme == NULL))
return FALSE;
- if (strcmp (scheme, "http") == 0 ||
- strcmp (scheme, "ws") == 0)
- return TRUE;
- else if (!aliases)
- return FALSE;
-
- for (int i = 0; aliases[i]; i++) {
- if (strcmp (scheme, aliases[i]) == 0)
- return TRUE;
- }
-
- return FALSE;
+ return strcmp (scheme, "http") == 0 || strcmp (scheme, "ws") == 0;
}
#define BASE64_INDICATOR ";base64"
diff --git a/tests/hsts-db-test.c b/tests/hsts-db-test.c
index 54b3bcb8..be3b817d 100644
--- a/tests/hsts-db-test.c
+++ b/tests/hsts-db-test.c
@@ -88,9 +88,9 @@ static void
rewrite_message_uri (SoupMessage *msg)
{
GUri *new_uri;
- if (soup_uri_is_http (soup_message_get_uri (msg), NULL))
+ if (soup_uri_is_http (soup_message_get_uri (msg)))
new_uri = soup_uri_copy (soup_message_get_uri (msg), SOUP_URI_PORT, g_uri_get_port (http_uri), SOUP_URI_NONE);
- else if (soup_uri_is_https (soup_message_get_uri (msg), NULL))
+ else if (soup_uri_is_https (soup_message_get_uri (msg)))
new_uri = soup_uri_copy (soup_message_get_uri (msg), SOUP_URI_PORT, g_uri_get_port (https_uri), SOUP_URI_NONE);
else
g_assert_not_reached();
diff --git a/tests/hsts-test.c b/tests/hsts-test.c
index a0276c77..4a5d0cd0 100644
--- a/tests/hsts-test.c
+++ b/tests/hsts-test.c
@@ -134,9 +134,9 @@ static void
rewrite_message_uri (SoupMessage *msg)
{
GUri *new_uri;
- if (soup_uri_is_http (soup_message_get_uri (msg), NULL))
+ if (soup_uri_is_http (soup_message_get_uri (msg)))
new_uri = soup_uri_copy (soup_message_get_uri (msg), SOUP_URI_PORT, g_uri_get_port (http_uri), SOUP_URI_NONE);
- else if (soup_uri_is_https (soup_message_get_uri (msg), NULL))
+ else if (soup_uri_is_https (soup_message_get_uri (msg)))
new_uri = soup_uri_copy (soup_message_get_uri (msg), SOUP_URI_PORT, g_uri_get_port (https_uri), SOUP_URI_NONE);
else
g_assert_not_reached();
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 80ee111e..7cee459a 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -7,8 +7,8 @@
#include "soup-connection.h"
#include "soup-session-private.h"
-SoupServer *server, *ssl_server;
-GUri *base_uri, *ssl_base_uri;
+SoupServer *server;
+GUri *base_uri;
static gboolean
auth_callback (SoupAuthDomain *auth_domain, SoupMessage *msg,
@@ -33,11 +33,8 @@ server_callback (SoupServer *server,
GHashTable *query,
gpointer data)
{
- SoupMessageHeaders *request_headers;
- SoupMessageHeaders *response_headers;
const char *method = soup_server_message_get_method (msg);
GUri *uri = soup_server_message_get_uri (msg);
- const char *server_protocol = data;
if (method != SOUP_METHOD_GET && method != SOUP_METHOD_POST) {
soup_server_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED, NULL);
@@ -49,37 +46,6 @@ server_callback (SoupServer *server,
return;
}
- request_headers = soup_server_message_get_request_headers (msg);
- response_headers = soup_server_message_get_response_headers (msg);
-
- if (!strcmp (path, "/alias-redirect")) {
- GUri *redirect_uri;
- char *redirect_string;
- const char *redirect_protocol;
- int redirect_port;
-
- redirect_protocol = soup_message_headers_get_one (request_headers, "X-Redirect-Protocol");
- if (!g_strcmp0 (redirect_protocol, "https"))
- redirect_port = g_uri_get_port (ssl_base_uri);
- else
- redirect_port = g_uri_get_port (base_uri);
-
- redirect_uri = g_uri_build (SOUP_HTTP_URI_FLAGS, "foo", NULL, g_uri_get_host (uri), redirect_port,
- "/alias-redirected", NULL, NULL);
- redirect_string = g_uri_to_string (redirect_uri);
-
- soup_server_message_set_redirect (msg, SOUP_STATUS_FOUND, redirect_string);
- g_free (redirect_string);
- g_uri_unref (redirect_uri);
- return;
- } else if (!strcmp (path, "/alias-redirected")) {
- soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
- soup_message_headers_append (response_headers,
- "X-Redirected-Protocol",
- server_protocol);
- return;
- }
-
if (!strcmp (path, "/slow")) {
GSource *timeout;
soup_server_pause_message (server, msg);
@@ -599,53 +565,6 @@ do_cancel_while_reading_preemptive_req_test (void)
}
static void
-do_aliases_test_for_session (SoupSession *session,
- const char *redirect_protocol)
-{
- SoupMessage *msg;
- GUri *uri;
- const char *redirected_protocol;
-
- uri = g_uri_parse_relative (base_uri, "/alias-redirect", SOUP_HTTP_URI_FLAGS, NULL);
- msg = soup_message_new_from_uri ("GET", uri);
- if (redirect_protocol)
- soup_message_headers_append (soup_message_get_request_headers (msg), "X-Redirect-Protocol", redirect_protocol);
- g_uri_unref (uri);
- soup_test_session_send_message (session, msg);
-
- redirected_protocol = soup_message_headers_get_one (soup_message_get_response_headers (msg), "X-Redirected-Protocol");
-
- g_assert_cmpstr (redirect_protocol, ==, redirected_protocol);
- if (redirect_protocol)
- soup_test_assert_message_status (msg, SOUP_STATUS_OK);
- else
- soup_test_assert_message_status (msg, SOUP_STATUS_FOUND);
-
- g_object_unref (msg);
-}
-
-static void
-do_aliases_test (void)
-{
- SoupSession *session;
- char *aliases[] = { "foo", NULL };
-
- if (tls_available) {
- debug_printf (1, " foo-means-https\n");
- session = soup_test_session_new ("https-aliases", aliases,
- NULL);
- do_aliases_test_for_session (session, "https");
- soup_test_session_abort_unref (session);
- } else
- debug_printf (1, " foo-means-https -- SKIPPING\n");
-
- debug_printf (1, " foo-means-nothing\n");
- session = soup_test_session_new (NULL);
- do_aliases_test_for_session (session, NULL);
- soup_test_session_abort_unref (session);
-}
-
-static void
do_msg_flags_test (void)
{
SoupMessage *msg;
@@ -711,7 +630,7 @@ main (int argc, char **argv)
test_init (argc, argv, NULL);
server = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD);
- soup_server_add_handler (server, NULL, server_callback, "http", NULL);
+ soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
base_uri = soup_test_server_get_uri (server, "http", NULL);
auth_domain = soup_auth_domain_basic_new (
@@ -722,12 +641,6 @@ main (int argc, char **argv)
soup_server_add_auth_domain (server, auth_domain);
g_object_unref (auth_domain);
- if (tls_available) {
- ssl_server = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD);
- soup_server_add_handler (ssl_server, NULL, server_callback, "https", NULL);
- ssl_base_uri = soup_test_server_get_uri (ssl_server, "https", "127.0.0.1");
- }
-
g_test_add_func ("/misc/bigheader", do_host_big_header);
g_test_add_func ("/misc/host", do_host_test);
g_test_add_func ("/misc/callback-unref/msg", do_callback_unref_test);
@@ -738,7 +651,6 @@ main (int argc, char **argv)
g_test_add_func ("/misc/cancel-while-reading/req/immediate", do_cancel_while_reading_immediate_req_test);
g_test_add_func ("/misc/cancel-while-reading/req/delayed", do_cancel_while_reading_delayed_req_test);
g_test_add_func ("/misc/cancel-while-reading/req/preemptive", do_cancel_while_reading_preemptive_req_test);
- g_test_add_func ("/misc/aliases", do_aliases_test);
g_test_add_func ("/misc/msg-flags", do_msg_flags_test);
ret = g_test_run ();
@@ -746,11 +658,6 @@ main (int argc, char **argv)
g_uri_unref (base_uri);
soup_test_server_quit_unref (server);
- if (tls_available) {
- g_uri_unref (ssl_base_uri);
- soup_test_server_quit_unref (ssl_server);
- }
-
test_cleanup ();
return ret;
}
diff --git a/tests/server-test.c b/tests/server-test.c
index 1ae6c385..8be65bfe 100644
--- a/tests/server-test.c
+++ b/tests/server-test.c
@@ -162,108 +162,6 @@ do_star_test (ServerData *sd, gconstpointer test_data)
}
static void
-do_one_server_aliases_test (GUri *uri,
- const char *alias,
- gboolean succeed)
-{
- GSocketClient *client;
- GSocketConnectable *addr;
- GSocketConnection *conn;
- GInputStream *in;
- GOutputStream *out;
- GError *error = NULL;
- GString *req;
- static char buf[1024];
-
- debug_printf (1, " %s via %s\n", alias, g_uri_get_scheme (uri));
-
- /* There's no way to make libsoup's client side send an absolute
- * URI (to a non-proxy server), so we have to fake this.
- */
-
- client = g_socket_client_new ();
- if (soup_uri_is_https (uri, NULL)) {
- g_socket_client_set_tls (client, TRUE);
- g_socket_client_set_tls_validation_flags (client, 0);
- }
- addr = g_network_address_new (g_uri_get_host (uri), g_uri_get_port (uri));
-
- conn = g_socket_client_connect (client, addr, NULL, &error);
- g_object_unref (addr);
- g_object_unref (client);
- if (!conn) {
- g_assert_no_error (error);
- g_error_free (error);
- return;
- }
-
- in = g_io_stream_get_input_stream (G_IO_STREAM (conn));
- out = g_io_stream_get_output_stream (G_IO_STREAM (conn));
-
- req = g_string_new (NULL);
- g_string_append_printf (req, "GET %s://%s:%d HTTP/1.1\r\n",
- alias, g_uri_get_host (uri), g_uri_get_port (uri));
- g_string_append_printf (req, "Host: %s:%d\r\n",
- g_uri_get_host (uri), g_uri_get_port (uri));
- g_string_append (req, "Connection: close\r\n\r\n");
-
- if (!g_output_stream_write_all (out, req->str, req->len, NULL, NULL, &error)) {
- g_assert_no_error (error);
- g_error_free (error);
- g_object_unref (conn);
- g_string_free (req, TRUE);
- return;
- }
- g_string_free (req, TRUE);
-
- if (!g_input_stream_read_all (in, buf, sizeof (buf), NULL, NULL, &error)) {
- g_assert_no_error (error);
- g_error_free (error);
- g_object_unref (conn);
- return;
- }
-
- if (succeed)
- g_assert_true (g_str_has_prefix (buf, "HTTP/1.1 200 "));
- else
- g_assert_true (g_str_has_prefix (buf, "HTTP/1.1 400 "));
-
- g_io_stream_close (G_IO_STREAM (conn), NULL, NULL);
- g_object_unref (conn);
-}
-
-static void
-do_server_aliases_test (ServerData *sd, gconstpointer test_data)
-{
- char *http_aliases[] = { "dav", NULL };
- char *https_aliases[] = { "davs", NULL };
- char *http_good[] = { "http", "dav", NULL };
- char *http_bad[] = { "https", "davs", "fred", NULL };
- char *https_good[] = { "https", "davs", NULL };
- char *https_bad[] = { "http", "dav", "fred", NULL };
- int i;
-
- g_test_bug ("703694");
-
- g_object_set (G_OBJECT (sd->server),
- "http-aliases", http_aliases,
- "https-aliases", https_aliases,
- NULL);
-
- for (i = 0; http_good[i]; i++)
- do_one_server_aliases_test (sd->base_uri, http_good[i], TRUE);
- for (i = 0; http_bad[i]; i++)
- do_one_server_aliases_test (sd->base_uri, http_bad[i], FALSE);
-
- if (tls_available) {
- for (i = 0; https_good[i]; i++)
- do_one_server_aliases_test (sd->ssl_base_uri, https_good[i], TRUE);
- for (i = 0; https_bad[i]; i++)
- do_one_server_aliases_test (sd->ssl_base_uri, https_bad[i], FALSE);
- }
-}
-
-static void
do_dot_dot_test (ServerData *sd, gconstpointer test_data)
{
SoupSession *session;
@@ -1407,8 +1305,6 @@ main (int argc, char **argv)
g_test_add ("/server/OPTIONS *", ServerData, NULL,
server_setup, do_star_test, server_teardown);
- g_test_add ("/server/aliases", ServerData, NULL,
- server_setup, do_server_aliases_test, server_teardown);
g_test_add ("/server/..-in-path", ServerData, NULL,
server_setup, do_dot_dot_test, server_teardown);
g_test_add ("/server/ipv6", ServerData, NULL,
diff --git a/tests/timeout-test.c b/tests/timeout-test.c
index 0e4128d2..d04fcd37 100644
--- a/tests/timeout-test.c
+++ b/tests/timeout-test.c
@@ -121,7 +121,7 @@ do_async_timeout_tests (gconstpointer data)
- if (soup_uri_is_https (fast_uri, NULL)) {
+ if (soup_uri_is_https (fast_uri)) {
SOUP_TEST_SKIP_IF_NO_TLS;
extra_slow = slow_https;
} else
@@ -161,7 +161,7 @@ do_sync_timeout_tests (gconstpointer data)
- if (soup_uri_is_https (fast_uri, NULL)) {
+ if (soup_uri_is_https (fast_uri)) {
SOUP_TEST_SKIP_IF_NO_TLS;
extra_slow = slow_https;