[libsoup] websocket: remove *_with_extentions variants
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] websocket: remove *_with_extentions variants
- Date: Thu, 5 Nov 2020 13:38:23 +0000 (UTC)
commit 252c2b39a657d4c0f9e841870cdf1482437eac62
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Thu Nov 5 14:10:18 2020 +0100
websocket: remove *_with_extentions variants
docs/reference/libsoup-3.0-sections.txt | 5 -
libsoup/server/soup-server.c | 20 +--
libsoup/soup-session.c | 16 +--
libsoup/websocket/soup-websocket-connection.c | 38 +----
libsoup/websocket/soup-websocket-connection.h | 12 +-
libsoup/websocket/soup-websocket.c | 191 +++-----------------------
libsoup/websocket/soup-websocket.h | 50 +++----
tests/websocket-test.c | 79 ++++++-----
8 files changed, 105 insertions(+), 306 deletions(-)
---
diff --git a/docs/reference/libsoup-3.0-sections.txt b/docs/reference/libsoup-3.0-sections.txt
index 2c590efe..cd222b48 100644
--- a/docs/reference/libsoup-3.0-sections.txt
+++ b/docs/reference/libsoup-3.0-sections.txt
@@ -974,19 +974,14 @@ SOUP_VERSION_PREV_STABLE
<FILE>soup-websocket</FILE>
<TITLE>SoupWebsocket</TITLE>
soup_websocket_client_prepare_handshake
-soup_websocket_client_prepare_handshake_with_extensions
soup_websocket_client_verify_handshake
-soup_websocket_client_verify_handshake_with_extensions
<SUBSECTION>
soup_websocket_server_check_handshake
-soup_websocket_server_check_handshake_with_extensions
soup_websocket_server_process_handshake
-soup_websocket_server_process_handshake_with_extensions
<SUBSECTION>
SoupWebsocketConnection
SoupWebsocketConnectionType
soup_websocket_connection_new
-soup_websocket_connection_new_with_extensions
soup_websocket_connection_get_io_stream
soup_websocket_connection_get_connection_type
soup_websocket_connection_get_uri
diff --git a/libsoup/server/soup-server.c b/libsoup/server/soup-server.c
index bc3f879d..33e4f6ee 100644
--- a/libsoup/server/soup-server.c
+++ b/libsoup/server/soup-server.c
@@ -920,11 +920,11 @@ complete_websocket_upgrade (SoupServer *server,
g_object_ref (msg);
stream = soup_server_message_steal_connection (msg);
- conn = soup_websocket_connection_new_with_extensions (stream, uri,
- SOUP_WEBSOCKET_CONNECTION_SERVER,
- soup_message_headers_get_one
(soup_server_message_get_request_headers (msg), "Origin"),
- soup_message_headers_get_one
(soup_server_message_get_response_headers (msg), "Sec-WebSocket-Protocol"),
- handler->websocket_extensions);
+ conn = soup_websocket_connection_new (stream, uri,
+ SOUP_WEBSOCKET_CONNECTION_SERVER,
+ soup_message_headers_get_one
(soup_server_message_get_request_headers (msg), "Origin"),
+ soup_message_headers_get_one
(soup_server_message_get_response_headers (msg), "Sec-WebSocket-Protocol"),
+ handler->websocket_extensions);
handler->websocket_extensions = NULL;
g_object_unref (stream);
@@ -959,11 +959,11 @@ got_body (SoupServer *server,
SoupServerPrivate *priv;
priv = soup_server_get_instance_private (server);
- if (soup_websocket_server_process_handshake_with_extensions (msg,
- handler->websocket_origin,
- handler->websocket_protocols,
- priv->websocket_extension_types,
- &handler->websocket_extensions))
{
+ if (soup_websocket_server_process_handshake (msg,
+ handler->websocket_origin,
+ handler->websocket_protocols,
+ priv->websocket_extension_types,
+ &handler->websocket_extensions)) {
g_signal_connect_object (msg, "wrote-informational",
G_CALLBACK (complete_websocket_upgrade),
server, G_CONNECT_SWAPPED);
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index e0c0a1bb..b40f3af5 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -3979,14 +3979,14 @@ websocket_connect_async_stop (SoupMessage *msg, gpointer user_data)
item->callback = NULL;
supported_extensions = soup_session_get_supported_websocket_extensions_for_message (session, msg);
- if (soup_websocket_client_verify_handshake_with_extensions (item->msg, supported_extensions,
&accepted_extensions, &error)) {
+ if (soup_websocket_client_verify_handshake (item->msg, supported_extensions, &accepted_extensions,
&error)) {
stream = soup_session_steal_connection (item->session, item->msg);
- client = soup_websocket_connection_new_with_extensions (stream,
- soup_message_get_uri (item->msg),
- SOUP_WEBSOCKET_CONNECTION_CLIENT,
- soup_message_headers_get_one
(soup_message_get_request_headers (msg), "Origin"),
- soup_message_headers_get_one
(soup_message_get_response_headers (msg), "Sec-WebSocket-Protocol"),
- accepted_extensions);
+ client = soup_websocket_connection_new (stream,
+ soup_message_get_uri (item->msg),
+ SOUP_WEBSOCKET_CONNECTION_CLIENT,
+ soup_message_headers_get_one
(soup_message_get_request_headers (msg), "Origin"),
+ soup_message_headers_get_one
(soup_message_get_response_headers (msg), "Sec-WebSocket-Protocol"),
+ accepted_extensions);
g_object_unref (stream);
g_task_return_pointer (task, client, g_object_unref);
g_object_unref (task);
@@ -4049,7 +4049,7 @@ soup_session_websocket_connect_async (SoupSession *session,
g_return_if_fail (SOUP_IS_MESSAGE (msg));
supported_extensions = soup_session_get_supported_websocket_extensions_for_message (session, msg);
- soup_websocket_client_prepare_handshake_with_extensions (msg, origin, protocols,
supported_extensions);
+ soup_websocket_client_prepare_handshake (msg, origin, protocols, supported_extensions);
/* When the client is to _Establish a WebSocket Connection_ given a set
* of (/host/, /port/, /resource name/, and /secure/ flag), along with a
diff --git a/libsoup/websocket/soup-websocket-connection.c b/libsoup/websocket/soup-websocket-connection.c
index ecce2e89..325a0b96 100644
--- a/libsoup/websocket/soup-websocket-connection.c
+++ b/libsoup/websocket/soup-websocket-connection.c
@@ -1743,49 +1743,21 @@ soup_websocket_connection_class_init (SoupWebsocketConnectionClass *klass)
* @type: the type of connection (client/side)
* @origin: (allow-none): the Origin of the client
* @protocol: (allow-none): the subprotocol in use
+ * @extensions: (element-type SoupWebsocketExtension) (transfer full): a #GList of #SoupWebsocketExtension
objects
*
- * Creates a #SoupWebsocketConnection on @stream. This should be
- * called after completing the handshake to begin using the WebSocket
+ * Creates a #SoupWebsocketConnection on @stream with the given active @extensions.
+ * This should be called after completing the handshake to begin using the WebSocket
* protocol.
*
* Returns: a new #SoupWebsocketConnection
- *
- * Since: 2.50
*/
SoupWebsocketConnection *
soup_websocket_connection_new (GIOStream *stream,
SoupURI *uri,
SoupWebsocketConnectionType type,
const char *origin,
- const char *protocol)
-{
- return soup_websocket_connection_new_with_extensions (stream, uri, type, origin, protocol, NULL);
-}
-
-/**
- * soup_websocket_connection_new_with_extensions:
- * @stream: a #GIOStream connected to the WebSocket server
- * @uri: the URI of the connection
- * @type: the type of connection (client/side)
- * @origin: (allow-none): the Origin of the client
- * @protocol: (allow-none): the subprotocol in use
- * @extensions: (element-type SoupWebsocketExtension) (transfer full): a #GList of #SoupWebsocketExtension
objects
- *
- * Creates a #SoupWebsocketConnection on @stream with the given active @extensions.
- * This should be called after completing the handshake to begin using the WebSocket
- * protocol.
- *
- * Returns: a new #SoupWebsocketConnection
- *
- * Since: 2.68
- */
-SoupWebsocketConnection *
-soup_websocket_connection_new_with_extensions (GIOStream *stream,
- SoupURI *uri,
- SoupWebsocketConnectionType type,
- const char *origin,
- const char *protocol,
- GList *extensions)
+ const char *protocol,
+ GList *extensions)
{
g_return_val_if_fail (G_IS_IO_STREAM (stream), NULL);
g_return_val_if_fail (uri != NULL, NULL);
diff --git a/libsoup/websocket/soup-websocket-connection.h b/libsoup/websocket/soup-websocket-connection.h
index 5cd4b8f6..6bd11bbd 100644
--- a/libsoup/websocket/soup-websocket-connection.h
+++ b/libsoup/websocket/soup-websocket-connection.h
@@ -29,19 +29,13 @@ G_BEGIN_DECLS
SOUP_AVAILABLE_IN_2_50
G_DECLARE_FINAL_TYPE (SoupWebsocketConnection, soup_websocket_connection, SOUP, WEBSOCKET_CONNECTION,
GObject)
-SOUP_AVAILABLE_IN_2_50
+SOUP_AVAILABLE_IN_ALL
SoupWebsocketConnection *soup_websocket_connection_new (GIOStream *stream,
SoupURI *uri,
SoupWebsocketConnectionType type,
const char *origin,
- const char *protocol);
-SOUP_AVAILABLE_IN_2_68
-SoupWebsocketConnection *soup_websocket_connection_new_with_extensions (GIOStream *stream,
- SoupURI *uri,
- SoupWebsocketConnectionType type,
- const char *origin,
- const char
*protocol,
- GList
*extensions);
+ const char *protocol,
+ GList *extensions);
SOUP_AVAILABLE_IN_2_50
GIOStream * soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self);
diff --git a/libsoup/websocket/soup-websocket.c b/libsoup/websocket/soup-websocket.c
index 9aeb4ba4..0a40d4c6 100644
--- a/libsoup/websocket/soup-websocket.c
+++ b/libsoup/websocket/soup-websocket.c
@@ -246,34 +246,6 @@ choose_subprotocol (SoupServerMessage *msg,
/**
* soup_websocket_client_prepare_handshake:
* @msg: a #SoupMessage
- * @origin: (allow-none): the "Origin" header to set
- * @protocols: (allow-none) (array zero-terminated=1): list of
- * protocols to offer
- *
- * Adds the necessary headers to @msg to request a WebSocket
- * handshake. The message body and non-WebSocket-related headers are
- * not modified.
- *
- * Use soup_websocket_client_prepare_handshake_with_extensions() if you
- * want to include "Sec-WebSocket-Extensions" header in the request.
- *
- * This is a low-level function; if you use
- * soup_session_websocket_connect_async() to create a WebSocket
- * connection, it will call this for you.
- *
- * Since: 2.50
- */
-void
-soup_websocket_client_prepare_handshake (SoupMessage *msg,
- const char *origin,
- char **protocols)
-{
- soup_websocket_client_prepare_handshake_with_extensions (msg, origin, protocols, NULL);
-}
-
-/**
- * soup_websocket_client_prepare_handshake_with_extensions:
- * @msg: a #SoupMessage
* @origin: (nullable): the "Origin" header to set
* @protocols: (nullable) (array zero-terminated=1): list of
* protocols to offer
@@ -288,14 +260,12 @@ soup_websocket_client_prepare_handshake (SoupMessage *msg,
* This is a low-level function; if you use
* soup_session_websocket_connect_async() to create a WebSocket
* connection, it will call this for you.
- *
- * Since: 2.68
*/
void
-soup_websocket_client_prepare_handshake_with_extensions (SoupMessage *msg,
- const char *origin,
- char **protocols,
- GPtrArray *supported_extensions)
+soup_websocket_client_prepare_handshake (SoupMessage *msg,
+ const char *origin,
+ char **protocols,
+ GPtrArray *supported_extensions)
{
guint32 raw[4];
char *key;
@@ -369,49 +339,6 @@ soup_websocket_client_prepare_handshake_with_extensions (SoupMessage *msg,
}
}
-/**
- * soup_websocket_server_check_handshake:
- * @msg: #SoupMessage containing the client side of a WebSocket handshake
- * @origin: (allow-none): expected Origin header
- * @protocols: (allow-none) (array zero-terminated=1): allowed WebSocket
- * protocols.
- * @error: return location for a #GError
- *
- * Examines the method and request headers in @msg and determines
- * whether @msg contains a valid handshake request.
- *
- * If @origin is non-%NULL, then only requests containing a matching
- * "Origin" header will be accepted. If @protocols is non-%NULL, then
- * only requests containing a compatible "Sec-WebSocket-Protocols"
- * header will be accepted.
- *
- * Requests containing "Sec-WebSocket-Extensions" header will be
- * accepted even if the header is not valid. To check a request
- * with extensions you need to use
- * soup_websocket_server_check_handshake_with_extensions() and provide
- * the list of supported extension types.
- *
- * Normally soup_websocket_server_process_handshake() will take care
- * of this for you, and if you use soup_server_add_websocket_handler()
- * to handle accepting WebSocket connections, it will call that for
- * you. However, this function may be useful if you need to perform
- * more complicated validation; eg, accepting multiple different Origins,
- * or handling different protocols depending on the path.
- *
- * Returns: %TRUE if @msg contained a valid WebSocket handshake,
- * %FALSE and an error if not.
- *
- * Since: 2.50
- */
-gboolean
-soup_websocket_server_check_handshake (SoupServerMessage *msg,
- const char *expected_origin,
- char **protocols,
- GError **error)
-{
- return soup_websocket_server_check_handshake_with_extensions (msg, expected_origin, protocols, NULL,
error);
-}
-
static gboolean
websocket_extension_class_equal (gconstpointer a,
gconstpointer b)
@@ -605,7 +532,7 @@ process_extensions (const char *extensions,
}
/**
- * soup_websocket_server_check_handshake_with_extensions:
+ * soup_websocket_server_check_handshake:
* @msg: #SoupServerMessage containing the client side of a WebSocket handshake
* @origin: (nullable): expected Origin header
* @protocols: (nullable) (array zero-terminated=1): allowed WebSocket
@@ -624,7 +551,7 @@ process_extensions (const char *extensions,
* only requests containing valid supported extensions in
* "Sec-WebSocket-Extensions" header will be accepted.
*
- * Normally soup_websocket_server_process_handshake_with_extensions()
+ * Normally soup_websocket_server_process_handshake()
* will take care of this for you, and if you use
* soup_server_add_websocket_handler() to handle accepting WebSocket
* connections, it will call that for you. However, this function may
@@ -634,15 +561,13 @@ process_extensions (const char *extensions,
*
* Returns: %TRUE if @msg contained a valid WebSocket handshake,
* %FALSE and an error if not.
- *
- * Since: 2.68
*/
gboolean
-soup_websocket_server_check_handshake_with_extensions (SoupServerMessage *msg,
- const char *expected_origin,
- char **protocols,
- GPtrArray *supported_extensions,
- GError **error)
+soup_websocket_server_check_handshake (SoupServerMessage *msg,
+ const char *expected_origin,
+ char **protocols,
+ GPtrArray *supported_extensions,
+ GError **error)
{
const char *origin;
const char *key;
@@ -747,45 +672,6 @@ respond_handshake_bad (SoupServerMessage *msg,
/**
* soup_websocket_server_process_handshake:
* @msg: #SoupServerMessage containing the client side of a WebSocket handshake
- * @expected_origin: (allow-none): expected Origin header
- * @protocols: (allow-none) (array zero-terminated=1): allowed WebSocket
- * protocols.
- *
- * Examines the method and request headers in @msg and (assuming @msg
- * contains a valid handshake request), fills in the handshake
- * response.
- *
- * If @expected_origin is non-%NULL, then only requests containing a matching
- * "Origin" header will be accepted. If @protocols is non-%NULL, then
- * only requests containing a compatible "Sec-WebSocket-Protocols"
- * header will be accepted.
- *
- * Requests containing "Sec-WebSocket-Extensions" header will be
- * accepted even if the header is not valid. To process a request
- * with extensions you need to use
- * soup_websocket_server_process_handshake_with_extensions() and provide
- * the list of supported extension types.
- *
- * This is a low-level function; if you use
- * soup_server_add_websocket_handler() to handle accepting WebSocket
- * connections, it will call this for you.
- *
- * Returns: %TRUE if @msg contained a valid WebSocket handshake
- * request and was updated to contain a handshake response. %FALSE if not.
- *
- * Since: 2.50
- */
-gboolean
-soup_websocket_server_process_handshake (SoupServerMessage *msg,
- const char *expected_origin,
- char **protocols)
-{
- return soup_websocket_server_process_handshake_with_extensions (msg, expected_origin, protocols,
NULL, NULL);
-}
-
-/**
- * soup_websocket_server_process_handshake_with_extensions:
- * @msg: #SoupServerMessage containing the client side of a WebSocket handshake
* @expected_origin: (nullable): expected Origin header
* @protocols: (nullable) (array zero-terminated=1): allowed WebSocket
* protocols.
@@ -812,15 +698,13 @@ soup_websocket_server_process_handshake (SoupServerMessage *msg,
*
* Returns: %TRUE if @msg contained a valid WebSocket handshake
* request and was updated to contain a handshake response. %FALSE if not.
- *
- * Since: 2.68
*/
gboolean
-soup_websocket_server_process_handshake_with_extensions (SoupServerMessage *msg,
- const char *expected_origin,
- char **protocols,
- GPtrArray *supported_extensions,
- GList **accepted_extensions)
+soup_websocket_server_process_handshake (SoupServerMessage *msg,
+ const char *expected_origin,
+ char **protocols,
+ GPtrArray *supported_extensions,
+ GList **accepted_extensions)
{
const char *chosen_protocol = NULL;
const char *key;
@@ -833,7 +717,7 @@ soup_websocket_server_process_handshake_with_extensions (SoupServerMessage *msg,
g_return_val_if_fail (SOUP_IS_SERVER_MESSAGE (msg), FALSE);
g_return_val_if_fail (accepted_extensions == NULL || *accepted_extensions == NULL, FALSE);
- if (!soup_websocket_server_check_handshake_with_extensions (msg, expected_origin, protocols,
supported_extensions, &error)) {
+ if (!soup_websocket_server_check_handshake (msg, expected_origin, protocols, supported_extensions,
&error)) {
if (g_error_matches (error,
SOUP_WEBSOCKET_ERROR,
SOUP_WEBSOCKET_ERROR_BAD_ORIGIN))
@@ -909,37 +793,6 @@ soup_websocket_server_process_handshake_with_extensions (SoupServerMessage *msg,
* soup_websocket_client_verify_handshake:
* @msg: #SoupMessage containing both client and server sides of a
* WebSocket handshake
- * @error: return location for a #GError
- *
- * Looks at the response status code and headers in @msg and
- * determines if they contain a valid WebSocket handshake response
- * (given the handshake request in @msg's request headers).
- *
- * If the response contains the "Sec-WebSocket-Extensions" header,
- * the handshake will be considered invalid. You need to use
- * soup_websocket_client_verify_handshake_with_extensions() to handle
- * responses with extensions.
- *
- * This is a low-level function; if you use
- * soup_session_websocket_connect_async() to create a WebSocket
- * connection, it will call this for you.
- *
- * Returns: %TRUE if @msg contains a completed valid WebSocket
- * handshake, %FALSE and an error if not.
- *
- * Since: 2.50
- */
-gboolean
-soup_websocket_client_verify_handshake (SoupMessage *msg,
- GError **error)
-{
- return soup_websocket_client_verify_handshake_with_extensions (msg, NULL, NULL, error);
-}
-
-/**
- * soup_websocket_client_verify_handshake_with_extensions:
- * @msg: #SoupMessage containing both client and server sides of a
- * WebSocket handshake
* @supported_extensions: (nullable) (element-type GObject.TypeClass): list
* of supported extension types
* @accepted_extensions: (out) (optional) (element-type SoupWebsocketExtension): a
@@ -960,14 +813,12 @@ soup_websocket_client_verify_handshake (SoupMessage *msg,
*
* Returns: %TRUE if @msg contains a completed valid WebSocket
* handshake, %FALSE and an error if not.
- *
- * Since: 2.68
*/
gboolean
-soup_websocket_client_verify_handshake_with_extensions (SoupMessage *msg,
- GPtrArray *supported_extensions,
- GList **accepted_extensions,
- GError **error)
+soup_websocket_client_verify_handshake (SoupMessage *msg,
+ GPtrArray *supported_extensions,
+ GList **accepted_extensions,
+ GError **error)
{
const char *protocol, *request_protocols, *extensions, *accept_key;
char *expected_accept_key;
diff --git a/libsoup/websocket/soup-websocket.h b/libsoup/websocket/soup-websocket.h
index c447b664..eb99f090 100644
--- a/libsoup/websocket/soup-websocket.h
+++ b/libsoup/websocket/soup-websocket.h
@@ -67,48 +67,30 @@ typedef enum {
SOUP_WEBSOCKET_STATE_CLOSED = 3,
} SoupWebsocketState;
-SOUP_AVAILABLE_IN_2_50
-void soup_websocket_client_prepare_handshake (SoupMessage *msg,
- const char *origin,
- char **protocols);
-SOUP_AVAILABLE_IN_2_68
-void soup_websocket_client_prepare_handshake_with_extensions (SoupMessage *msg,
- const char *origin,
- char **protocols,
- GPtrArray *supported_extensions);
+SOUP_AVAILABLE_IN_ALL
+void soup_websocket_client_prepare_handshake (SoupMessage *msg,
+ const char *origin,
+ char **protocols,
+ GPtrArray *supported_extensions);
-SOUP_AVAILABLE_IN_2_50
-gboolean soup_websocket_client_verify_handshake (SoupMessage *msg,
- GError **error);
-SOUP_AVAILABLE_IN_2_68
-gboolean soup_websocket_client_verify_handshake_with_extensions (SoupMessage *msg,
- GPtrArray *supported_extensions,
- GList **accepted_extensions,
- GError **error);
+SOUP_AVAILABLE_IN_ALL
+gboolean soup_websocket_client_verify_handshake (SoupMessage *msg,
+ GPtrArray *supported_extensions,
+ GList **accepted_extensions,
+ GError **error);
-SOUP_AVAILABLE_IN_2_50
+SOUP_AVAILABLE_IN_ALL
gboolean soup_websocket_server_check_handshake (SoupServerMessage *msg,
const char *origin,
char **protocols,
+ GPtrArray *supported_extensions,
GError **error);
-SOUP_AVAILABLE_IN_2_68
-gboolean
-soup_websocket_server_check_handshake_with_extensions (SoupServerMessage *msg,
- const char *origin,
- char **protocols,
- GPtrArray *supported_extensions,
- GError **error);
-SOUP_AVAILABLE_IN_2_50
+SOUP_AVAILABLE_IN_ALL
gboolean soup_websocket_server_process_handshake (SoupServerMessage *msg,
const char *expected_origin,
- char **protocols);
-SOUP_AVAILABLE_IN_2_68
-gboolean
-soup_websocket_server_process_handshake_with_extensions (SoupServerMessage *msg,
- const char *expected_origin,
- char **protocols,
- GPtrArray *supported_extensions,
- GList **accepted_extensions);
+ char **protocols,
+ GPtrArray *supported_extensions,
+ GList **accepted_extensions);
G_END_DECLS
diff --git a/tests/websocket-test.c b/tests/websocket-test.c
index f2790b7d..03a57172 100644
--- a/tests/websocket-test.c
+++ b/tests/websocket-test.c
@@ -123,10 +123,10 @@ direct_connection_complete (GObject *object,
NULL, NULL));
extensions = g_list_prepend (extensions, extension);
}
- test->client = soup_websocket_connection_new_with_extensions (G_IO_STREAM (conn), uri,
- SOUP_WEBSOCKET_CONNECTION_CLIENT,
- NULL, NULL,
- extensions);
+ test->client = soup_websocket_connection_new (G_IO_STREAM (conn), uri,
+ SOUP_WEBSOCKET_CONNECTION_CLIENT,
+ NULL, NULL,
+ extensions);
soup_uri_free (uri);
g_object_unref (conn);
}
@@ -163,10 +163,10 @@ got_connection (GSocket *listener,
NULL, NULL));
extensions = g_list_prepend (extensions, extension);
}
- test->server = soup_websocket_connection_new_with_extensions (G_IO_STREAM (conn), uri,
-
SOUP_WEBSOCKET_CONNECTION_SERVER,
- NULL, NULL,
- extensions);
+ test->server = soup_websocket_connection_new (G_IO_STREAM (conn), uri,
+ SOUP_WEBSOCKET_CONNECTION_SERVER,
+ NULL, NULL,
+ extensions);
soup_uri_free (uri);
g_object_unref (conn);
}
@@ -652,7 +652,8 @@ test_protocol_negotiate_direct (Test *test,
msg = soup_message_new ("GET", "http://127.0.0.1");
soup_websocket_client_prepare_handshake (msg, NULL,
- (char **) negotiate_client_protocols);
+ (char **) negotiate_client_protocols,
+ NULL);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
soup_server_message_set_method (server_msg, soup_message_get_method (msg));
@@ -663,12 +664,14 @@ test_protocol_negotiate_direct (Test *test,
soup_message_headers_append (request_headers, name, value);
ok = soup_websocket_server_check_handshake (server_msg, NULL,
(char **) negotiate_server_protocols,
+ NULL,
&error);
g_assert_no_error (error);
g_assert_true (ok);
ok = soup_websocket_server_process_handshake (server_msg, NULL,
- (char **) negotiate_server_protocols);
+ (char **) negotiate_server_protocols,
+ NULL, NULL);
g_assert_true (ok);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
@@ -679,7 +682,7 @@ test_protocol_negotiate_direct (Test *test,
protocol = soup_message_headers_get_one (soup_message_get_response_headers (msg),
"Sec-WebSocket-Protocol");
g_assert_cmpstr (protocol, ==, negotiated_protocol);
- ok = soup_websocket_client_verify_handshake (msg, &error);
+ ok = soup_websocket_client_verify_handshake (msg, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (ok);
@@ -720,7 +723,8 @@ test_protocol_mismatch_direct (Test *test,
msg = soup_message_new ("GET", "http://127.0.0.1");
soup_websocket_client_prepare_handshake (msg, NULL,
- (char **) mismatch_client_protocols);
+ (char **) mismatch_client_protocols,
+ NULL);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
soup_server_message_set_method (server_msg, soup_message_get_method (msg));
@@ -731,13 +735,14 @@ test_protocol_mismatch_direct (Test *test,
soup_message_headers_append (request_headers, name, value);
ok = soup_websocket_server_check_handshake (server_msg, NULL,
(char **) mismatch_server_protocols,
- &error);
+ NULL, &error);
g_assert_error (error, SOUP_WEBSOCKET_ERROR, SOUP_WEBSOCKET_ERROR_BAD_HANDSHAKE);
g_clear_error (&error);
g_assert_false (ok);
ok = soup_websocket_server_process_handshake (server_msg, NULL,
- (char **) mismatch_server_protocols);
+ (char **) mismatch_server_protocols,
+ NULL, NULL);
g_assert_false (ok);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
soup_test_assert_message_status (msg, SOUP_STATUS_BAD_REQUEST);
@@ -749,7 +754,7 @@ test_protocol_mismatch_direct (Test *test,
protocol = soup_message_headers_get_one (soup_message_get_response_headers (msg),
"Sec-WebSocket-Protocol");
g_assert_cmpstr (protocol, ==, NULL);
- ok = soup_websocket_client_verify_handshake (msg, &error);
+ ok = soup_websocket_client_verify_handshake (msg, NULL, NULL, &error);
g_assert_error (error, SOUP_WEBSOCKET_ERROR, SOUP_WEBSOCKET_ERROR_BAD_HANDSHAKE);
g_clear_error (&error);
g_assert_false (ok);
@@ -786,7 +791,7 @@ test_protocol_server_any_direct (Test *test,
GError *error = NULL;
msg = soup_message_new ("GET", "http://127.0.0.1");
- soup_websocket_client_prepare_handshake (msg, NULL, (char **) all_protocols);
+ soup_websocket_client_prepare_handshake (msg, NULL, (char **) all_protocols, NULL);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
soup_server_message_set_method (server_msg, soup_message_get_method (msg));
@@ -795,11 +800,11 @@ test_protocol_server_any_direct (Test *test,
soup_message_headers_iter_init (&iter, soup_message_get_request_headers (msg));
while (soup_message_headers_iter_next (&iter, &name, &value))
soup_message_headers_append (request_headers, name, value);
- ok = soup_websocket_server_check_handshake (server_msg, NULL, NULL, &error);
+ ok = soup_websocket_server_check_handshake (server_msg, NULL, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (ok);
- ok = soup_websocket_server_process_handshake (server_msg, NULL, NULL);
+ ok = soup_websocket_server_process_handshake (server_msg, NULL, NULL, NULL, NULL);
g_assert_true (ok);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
@@ -810,7 +815,7 @@ test_protocol_server_any_direct (Test *test,
protocol = soup_message_headers_get_one (soup_message_get_response_headers (msg),
"Sec-WebSocket-Protocol");
g_assert_cmpstr (protocol, ==, NULL);
- ok = soup_websocket_client_verify_handshake (msg, &error);
+ ok = soup_websocket_client_verify_handshake (msg, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (ok);
@@ -848,7 +853,7 @@ test_protocol_client_any_direct (Test *test,
GError *error = NULL;
msg = soup_message_new ("GET", "http://127.0.0.1");
- soup_websocket_client_prepare_handshake (msg, NULL, NULL);
+ soup_websocket_client_prepare_handshake (msg, NULL, NULL, NULL);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
soup_server_message_set_method (server_msg, soup_message_get_method (msg));
@@ -857,11 +862,11 @@ test_protocol_client_any_direct (Test *test,
soup_message_headers_iter_init (&iter, soup_message_get_request_headers (msg));
while (soup_message_headers_iter_next (&iter, &name, &value))
soup_message_headers_append (request_headers, name, value);
- ok = soup_websocket_server_check_handshake (server_msg, NULL, (char **) all_protocols, &error);
+ ok = soup_websocket_server_check_handshake (server_msg, NULL, (char **) all_protocols, NULL, &error);
g_assert_no_error (error);
g_assert_true (ok);
- ok = soup_websocket_server_process_handshake (server_msg, NULL, (char **) all_protocols);
+ ok = soup_websocket_server_process_handshake (server_msg, NULL, (char **) all_protocols, NULL, NULL);
g_assert_true (ok);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
@@ -872,7 +877,7 @@ test_protocol_client_any_direct (Test *test,
protocol = soup_message_headers_get_one (soup_message_get_response_headers (msg),
"Sec-WebSocket-Protocol");
g_assert_cmpstr (protocol, ==, NULL);
- ok = soup_websocket_client_verify_handshake (msg, &error);
+ ok = soup_websocket_client_verify_handshake (msg, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (ok);
@@ -1695,7 +1700,7 @@ test_deflate_negotiate_direct (Test *test,
msg = soup_message_new ("GET", "http://127.0.0.1");
- soup_websocket_client_prepare_handshake (msg, NULL, NULL);
+ soup_websocket_client_prepare_handshake (msg, NULL, NULL, NULL);
soup_message_headers_append (soup_message_get_request_headers (msg),
"Sec-WebSocket-Extensions", deflate_negotiate_tests[i].client_extension);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
@@ -1705,10 +1710,10 @@ test_deflate_negotiate_direct (Test *test,
soup_message_headers_iter_init (&iter, soup_message_get_request_headers (msg));
while (soup_message_headers_iter_next (&iter, &name, &value))
soup_message_headers_append (request_headers, name, value);
- result = soup_websocket_server_check_handshake_with_extensions (server_msg, NULL, NULL,
-
deflate_negotiate_tests[i].server_supports_extensions ?
- supported_extensions : NULL,
- &error);
+ result = soup_websocket_server_check_handshake (server_msg, NULL, NULL,
+
deflate_negotiate_tests[i].server_supports_extensions ?
+ supported_extensions : NULL,
+ &error);
g_assert (result == deflate_negotiate_tests[i].expected_check_result);
if (result) {
g_assert_no_error (error);
@@ -1717,10 +1722,10 @@ test_deflate_negotiate_direct (Test *test,
g_clear_error (&error);
}
- result = soup_websocket_server_process_handshake_with_extensions (server_msg, NULL, NULL,
-
deflate_negotiate_tests[i].server_supports_extensions ?
- supported_extensions : NULL,
- &accepted_extensions);
+ result = soup_websocket_server_process_handshake (server_msg, NULL, NULL,
+
deflate_negotiate_tests[i].server_supports_extensions ?
+ supported_extensions : NULL,
+ &accepted_extensions);
g_assert (result == deflate_negotiate_tests[i].expected_check_result);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
@@ -1742,7 +1747,7 @@ test_deflate_negotiate_direct (Test *test,
g_assert_null (accepted_extensions);
}
- result = soup_websocket_client_verify_handshake_with_extensions (msg, supported_extensions,
&accepted_extensions, &error);
+ result = soup_websocket_client_verify_handshake (msg, supported_extensions,
&accepted_extensions, &error);
g_assert (result == deflate_negotiate_tests[i].expected_verify_result);
if (result) {
g_assert_no_error (error);
@@ -1786,7 +1791,7 @@ test_deflate_disabled_in_message_direct (Test *test,
msg = soup_message_new ("GET", "http://127.0.0.1");
soup_message_disable_feature (msg, SOUP_TYPE_WEBSOCKET_EXTENSION_DEFLATE);
- soup_websocket_client_prepare_handshake_with_extensions (msg, NULL, NULL, supported_extensions);
+ soup_websocket_client_prepare_handshake (msg, NULL, NULL, supported_extensions);
g_assert_cmpstr (soup_message_headers_get_one (soup_message_get_request_headers (msg),
"Sec-WebSocket-Extensions"), ==, NULL);
server_msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
@@ -1797,10 +1802,10 @@ test_deflate_disabled_in_message_direct (Test *test,
while (soup_message_headers_iter_next (&iter, &name, &value))
soup_message_headers_append (request_headers, name, value);
- g_assert_true (soup_websocket_server_check_handshake_with_extensions (server_msg, NULL, NULL,
supported_extensions, &error));
+ g_assert_true (soup_websocket_server_check_handshake (server_msg, NULL, NULL, supported_extensions,
&error));
g_assert_no_error (error);
- g_assert_true (soup_websocket_server_process_handshake_with_extensions (server_msg, NULL, NULL,
supported_extensions, &accepted_extensions));
+ g_assert_true (soup_websocket_server_process_handshake (server_msg, NULL, NULL, supported_extensions,
&accepted_extensions));
g_assert_null (accepted_extensions);
soup_message_set_status (msg, soup_server_message_get_status (server_msg, NULL));
response_headers = soup_server_message_get_response_headers (server_msg);
@@ -1809,7 +1814,7 @@ test_deflate_disabled_in_message_direct (Test *test,
soup_message_headers_append (soup_message_get_response_headers (msg), name, value);
g_assert_cmpstr (soup_message_headers_get_one (soup_message_get_response_headers (msg),
"Sec-WebSocket-Extensions"), ==, NULL);
- g_assert_true (soup_websocket_client_verify_handshake_with_extensions (msg, supported_extensions,
&accepted_extensions, &error));
+ g_assert_true (soup_websocket_client_verify_handshake (msg, supported_extensions,
&accepted_extensions, &error));
g_assert_no_error (error);
g_assert_null (accepted_extensions);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]