[evolution-ews/wip/mcrha/soup3] Some basic replacements



commit 9fc53e7b75cc2aa9a1dbc3bd646c61aa502a8dc2
Author: Milan Crha <mcrha redhat com>
Date:   Thu Dec 9 12:21:06 2021 +0100

    Some basic replacements

 CMakeLists.txt                                     |  10 +-
 src/EWS/addressbook/e-book-backend-ews.c           |  12 +-
 src/EWS/calendar/e-cal-backend-ews.c               |  12 +-
 src/EWS/common/camel-ews-settings.c                |   8 +-
 src/EWS/common/e-ews-connection-utils.c            |  68 ++++---
 src/EWS/common/e-ews-connection.c                  | 130 ++++--------
 src/EWS/common/e-ews-debug.c                       |  64 ------
 src/EWS/common/e-ews-debug.h                       |   4 -
 src/EWS/common/e-ews-message.c                     |   8 +-
 src/EWS/common/e-ews-notification.c                |  46 ++---
 src/EWS/common/e-oauth2-service-office365.c        |  12 +-
 src/EWS/common/e-soup-auth-negotiate.c             |  18 +-
 src/EWS/evolution/e-ews-config-lookup.c            |  36 ++--
 src/EWS/evolution/e-mail-config-ews-backend.c      |  16 +-
 src/EWS/registry/e-ews-backend.c                   |  12 +-
 src/Microsoft365/camel/camel-m365-folder.c         |   4 +-
 src/Microsoft365/common/e-m365-connection.c        | 219 ++++++++++++---------
 .../common/e-oauth2-service-microsoft365.c         |  12 +-
 18 files changed, 304 insertions(+), 387 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f108f55a..375ab40d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,16 +18,16 @@ set(PROJECT_DISTCONFIGURE_PARAMS
 )
 
 # Keep these two definitions in agreement.
-set(glib_minimum_version 2.62)
-set(glib_encoded_version GLIB_VERSION_2_62)
+set(glib_minimum_version 2.68)
+set(glib_encoded_version GLIB_VERSION_2_68)
 
 # Keep these two definitions in agreement.
 set(gdk_minimum_version 3.10)
 set(gdk_encoded_version GDK_VERSION_3_10)
 
 # Keep these two definitions in agreement.
-set(soup_minimum_version 2.58)
-set(soup_encoded_version SOUP_VERSION_2_58)
+set(soup_minimum_version 3.0)
+set(soup_encoded_version SOUP_VERSION_3_0)
 
 # Warn about API usage that violates our minimum requirements.
 add_definitions(-DGLIB_VERSION_MAX_ALLOWED=${glib_encoded_version})
@@ -139,7 +139,7 @@ pkg_check_modules(GNOME_PLATFORM REQUIRED
        gtk+-3.0>=${gdk_minimum_version}
 )
 
-pkg_check_modules(SOUP REQUIRED libsoup-2.4>=${soup_minimum_version})
+pkg_check_modules(SOUP REQUIRED libsoup-3.0>=${soup_minimum_version})
 
 pkg_check_modules(LIBICAL_GLIB REQUIRED libical-glib>=${libical_glib_minimum_version})
 
diff --git a/src/EWS/addressbook/e-book-backend-ews.c b/src/EWS/addressbook/e-book-backend-ews.c
index bf10b850..7a021774 100644
--- a/src/EWS/addressbook/e-book-backend-ews.c
+++ b/src/EWS/addressbook/e-book-backend-ews.c
@@ -4552,7 +4552,7 @@ ebb_ews_get_destination_address (EBackend *backend,
                                 guint16 *port)
 {
        CamelEwsSettings *ews_settings;
-       SoupURI *soup_uri;
+       GUri *uri;
        gchar *host_url;
        gboolean result = FALSE;
 
@@ -4570,10 +4570,10 @@ ebb_ews_get_destination_address (EBackend *backend,
        host_url = camel_ews_settings_dup_hosturl (ews_settings);
        g_return_val_if_fail (host_url != NULL, FALSE);
 
-       soup_uri = soup_uri_new (host_url);
-       if (soup_uri) {
-               *host = g_strdup (soup_uri_get_host (soup_uri));
-               *port = soup_uri_get_port (soup_uri);
+       uri = g_uri_parse (host_url, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+       if (uri) {
+               *host = g_strdup (g_uri_get_host (uri));
+               *port = g_uri_get_port (uri);
 
                result = *host && **host;
                if (!result) {
@@ -4581,7 +4581,7 @@ ebb_ews_get_destination_address (EBackend *backend,
                        *host = NULL;
                }
 
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        g_free (host_url);
diff --git a/src/EWS/calendar/e-cal-backend-ews.c b/src/EWS/calendar/e-cal-backend-ews.c
index ea7c1f78..5bc3ac65 100644
--- a/src/EWS/calendar/e-cal-backend-ews.c
+++ b/src/EWS/calendar/e-cal-backend-ews.c
@@ -4546,7 +4546,7 @@ ecb_ews_get_destination_address (EBackend *backend,
                                 guint16 *port)
 {
        CamelEwsSettings *ews_settings;
-       SoupURI *soup_uri;
+       GUri *uri;
        gchar *host_url;
        gboolean result = FALSE;
 
@@ -4564,10 +4564,10 @@ ecb_ews_get_destination_address (EBackend *backend,
        host_url = camel_ews_settings_dup_hosturl (ews_settings);
        g_return_val_if_fail (host_url != NULL, FALSE);
 
-       soup_uri = soup_uri_new (host_url);
-       if (soup_uri) {
-               *host = g_strdup (soup_uri_get_host (soup_uri));
-               *port = soup_uri_get_port (soup_uri);
+       uri = g_uri_parse (host_url, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+       if (uri) {
+               *host = g_strdup (g_uri_get_host (uri));
+               *port = g_uri_get_port (uri);
 
                result = *host && **host;
                if (!result) {
@@ -4575,7 +4575,7 @@ ecb_ews_get_destination_address (EBackend *backend,
                        *host = NULL;
                }
 
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        g_free (host_url);
diff --git a/src/EWS/common/camel-ews-settings.c b/src/EWS/common/camel-ews-settings.c
index e2cbb8a5..91ca849d 100644
--- a/src/EWS/common/camel-ews-settings.c
+++ b/src/EWS/common/camel-ews-settings.c
@@ -85,19 +85,19 @@ ews_settings_transform_host_url_to_host_cb (GBinding *binding,
 
        host_url = g_value_get_string (host_url_value);
        if (host_url && *host_url) {
-               SoupURI *uri;
+               GUri *uri;
 
-               uri = soup_uri_new (host_url);
+               uri = g_uri_parse (host_url, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
                if (uri) {
                        const gchar *host;
 
-                       host = soup_uri_get_host (uri);
+                       host = g_uri_get_host (uri);
                        if (!host || !*host)
                                host = "";
 
                        g_value_set_string (host_value, host);
 
-                       soup_uri_free (uri);
+                       g_uri_unref (uri);
                }
        }
 
diff --git a/src/EWS/common/e-ews-connection-utils.c b/src/EWS/common/e-ews-connection-utils.c
index a9616d59..89cb108e 100644
--- a/src/EWS/common/e-ews-connection-utils.c
+++ b/src/EWS/common/e-ews-connection-utils.c
@@ -195,13 +195,19 @@ e_ews_connection_utils_check_x_ms_credential_headers (SoupMessage *message,
                                                      gboolean *out_expired,
                                                      gchar **out_service_url)
 {
+       SoupMessageHedaers *response_headers;
        gboolean any_found = FALSE;
        const gchar *header;
 
-       if (!message || !message->response_headers)
+       if (!message)
                return FALSE;
 
-       header = soup_message_headers_get_list (message->response_headers, 
"X-MS-Credential-Service-CredExpired");
+       response_headers = soup_message_get_response_headers (message);
+
+       if (!response_headers)
+               return FALSE;
+
+       header = soup_message_headers_get_list (response_headers, "X-MS-Credential-Service-CredExpired");
        if (header && g_ascii_strcasecmp (header, "true") == 0) {
                any_found = TRUE;
 
@@ -209,7 +215,7 @@ e_ews_connection_utils_check_x_ms_credential_headers (SoupMessage *message,
                        *out_expired = TRUE;
        }
 
-       header = soup_message_headers_get_list (message->response_headers, "X-MS-Credentials-Expire");
+       header = soup_message_headers_get_list (response_headers, "X-MS-Credentials-Expire");
        if (header) {
                gint in_days;
 
@@ -223,7 +229,7 @@ e_ews_connection_utils_check_x_ms_credential_headers (SoupMessage *message,
        }
 
        if (any_found && out_service_url) {
-               header = soup_message_headers_get_list (message->response_headers, 
"X-MS-Credential-Service-Url");
+               header = soup_message_headers_get_list (response_headers, "X-MS-Credential-Service-Url");
 
                *out_service_url = g_strdup (header);
        }
@@ -257,7 +263,7 @@ ews_connection_utils_ensure_bearer_auth_usage (SoupSession *session,
 {
        SoupAuthManager *auth_manager;
        SoupSessionFeature *feature;
-       SoupURI *soup_uri;
+       GUri *uri;
 
        g_return_if_fail (SOUP_IS_SESSION (session));
 
@@ -267,28 +273,35 @@ ews_connection_utils_ensure_bearer_auth_usage (SoupSession *session,
 
        feature = soup_session_get_feature (SOUP_SESSION (session), SOUP_TYPE_AUTH_MANAGER);
 
-       if (!soup_session_feature_has_feature (feature, E_TYPE_SOUP_AUTH_BEARER)) {
+       if (!soup_session_has_feature (SOUP_SESSION (session), E_TYPE_SOUP_AUTH_BEARER)) {
                /* Add the "Bearer" auth type to support OAuth 2.0. */
-               soup_session_feature_add_feature (feature, E_TYPE_SOUP_AUTH_BEARER);
+               soup_session_add_feature_by_type (SOUP_SESSION (session), E_TYPE_SOUP_AUTH_BEARER);
        }
 
-       soup_uri = message ? soup_message_get_uri (message) : NULL;
-       if (soup_uri && soup_uri->host && *soup_uri->host) {
-               soup_uri = soup_uri_copy_host (soup_uri);
+       uri = message ? soup_message_get_uri (message) : NULL;
+       if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
+               uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
+                       g_uri_get_scheme (uri),
+                       NULL /* userinfo */,
+                       g_uri_get_host (uri),
+                       g_uri_get_port (uri),
+                       NULL /* path */,
+                       NULL /* query */,
+                       NULL /* fragment */);
        } else {
-               soup_uri = NULL;
+               uri = NULL;
        }
 
-       g_return_if_fail (soup_uri != NULL);
+       g_return_if_fail (uri != NULL);
 
        auth_manager = SOUP_AUTH_MANAGER (feature);
 
        /* This will make sure the 'bearer' is used regardless of the current 'auth_manager' state.
           See https://gitlab.gnome.org/GNOME/libsoup/-/issues/196 for more information. */
        soup_auth_manager_clear_cached_credentials (auth_manager);
-       soup_auth_manager_use_auth (auth_manager, soup_uri, SOUP_AUTH (bearer));
+       soup_auth_manager_use_auth (auth_manager, uri, SOUP_AUTH (bearer));
 
-       soup_uri_free (soup_uri);
+       g_uri_unref (uri);
 }
 
 static gboolean
@@ -386,30 +399,37 @@ ews_connection_utils_maybe_prepare_bearer_auth (EEwsConnection *cnc,
                g_clear_object (&using_bearer_auth);
        } else {
                SoupAuth *soup_auth;
-               SoupURI *soup_uri;
-
-               soup_uri = message ? soup_message_get_uri (message) : NULL;
-               if (soup_uri && soup_uri->host && *soup_uri->host) {
-                       soup_uri = soup_uri_copy_host (soup_uri);
+               GUri *uri;
+
+               uri = message ? soup_message_get_uri (message) : NULL;
+               if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
+                       uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
+                               g_uri_get_scheme (uri),
+                               NULL /* userinfo */,
+                               g_uri_get_host (uri),
+                               g_uri_get_port (uri),
+                               NULL /* path */,
+                               NULL /* query */,
+                               NULL /* fragment */);
                } else {
-                       soup_uri = NULL;
+                       uri = NULL;
                }
 
-               g_warn_if_fail (soup_uri != NULL);
+               g_warn_if_fail (uri != NULL);
 
-               if (!soup_uri) {
+               if (!uri) {
                        soup_message_set_status_full (message, SOUP_STATUS_MALFORMED, "Cannot get host from 
message");
                        return FALSE;
                }
 
-               soup_auth = g_object_new (E_TYPE_SOUP_AUTH_BEARER, SOUP_AUTH_HOST, soup_uri->host, NULL);
+               soup_auth = g_object_new (E_TYPE_SOUP_AUTH_BEARER, SOUP_AUTH_HOST, g_uri_get_host (uri), 
NULL);
 
                success = ews_connection_utils_setup_bearer_auth (cnc, session, message, FALSE, 
E_SOUP_AUTH_BEARER (soup_auth), cancellable, &local_error);
                if (success)
                        e_ews_connection_set_bearer_auth (cnc, E_SOUP_AUTH_BEARER (soup_auth));
 
                g_object_unref (soup_auth);
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        if (!success) {
diff --git a/src/EWS/common/e-ews-connection.c b/src/EWS/common/e-ews-connection.c
index 8bf646cd..d2469b07 100644
--- a/src/EWS/common/e-ews-connection.c
+++ b/src/EWS/common/e-ews-connection.c
@@ -46,8 +46,7 @@ static gint comp_func (gconstpointer a, gconstpointer b);
 
 static void ews_response_cb (SoupSession *session, SoupMessage *msg, gpointer data);
 
-static void    ews_connection_authenticate     (SoupSession *sess,
-                                                SoupMessage *msg,
+static gboolean        ews_connection_authenticate     (SoupMessage *msg,
                                                 SoupAuth *auth,
                                                 gboolean retrying,
                                                 gpointer data);
@@ -555,21 +554,16 @@ ews_connection_scheduled_cb (gpointer user_data)
        switch (sd->op) {
        case EWS_SCHEDULE_OP_QUEUE_MESSAGE:
                if (!e_ews_connection_utils_prepare_message (sd->cnc, NULL, sd->message, NULL)) {
-                       e_ews_debug_dump_raw_soup_request (sd->message);
-
                        if (sd->queue_callback) {
                                sd->queue_callback (sd->cnc->priv->soup_session, sd->message, 
sd->queue_user_data);
                        } else {
                                /* This should not happen */
                                g_warn_if_reached ();
-
-                               soup_session_queue_message (
-                                       sd->cnc->priv->soup_session, sd->message,
-                                       sd->queue_callback, sd->queue_user_data);
-                               soup_session_cancel_message (sd->cnc->priv->soup_session, sd->message, 
sd->message->status_code);
                        }
                } else {
-                       e_ews_debug_dump_raw_soup_request (sd->message);
+                       g_signal_connect (
+                               sd->message, "authenticate",
+                               G_CALLBACK (ews_connection_authenticate), cnc);
 
                        soup_session_queue_message (
                                sd->cnc->priv->soup_session, sd->message,
@@ -717,11 +711,8 @@ ews_next_request (gpointer _cnc)
                SoupMessage *msg = SOUP_MESSAGE (node->msg);
 
                if (!e_ews_connection_utils_prepare_message (cnc, NULL, msg, node->cancellable)) {
-                       e_ews_debug_dump_raw_soup_request (msg);
-
                        ews_response_cb (cnc->priv->soup_session, msg, node);
                } else {
-                       e_ews_debug_dump_raw_soup_request (msg);
                        soup_session_queue_message (cnc->priv->soup_session, msg, ews_response_cb, node);
                }
        } else {
@@ -925,10 +916,9 @@ ews_response_cb (SoupSession *session,
        ESoapResponse *response;
        ESoapParameter *param;
        const gchar *persistent_auth;
-       gint log_level;
        gint wait_ms = 0;
 
-       persistent_auth = soup_message_headers_get_one (msg->response_headers, "Persistent-Auth");
+       persistent_auth = soup_message_headers_get_one (soup_message_get_response_headers (msg), 
"Persistent-Auth");
        if (persistent_auth && g_ascii_strcasecmp (persistent_auth, "false") == 0) {
                SoupSessionFeature *feature;
 
@@ -950,11 +940,11 @@ ews_response_cb (SoupSession *session,
                        enode->simple, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED,
                        "%s", msg->reason_phrase);
                goto exit;
-       } else if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) {
-               if (msg->response_headers) {
+       } else if (soup_message_get_status (msg) == SOUP_STATUS_UNAUTHORIZED) {
+               if (soup_message_get_response_headers (msg)) {
                        const gchar *diagnostics;
 
-                       diagnostics = soup_message_headers_get_list (msg->response_headers, 
"X-MS-DIAGNOSTICS");
+                       diagnostics = soup_message_headers_get_list (soup_message_get_response_headers (msg), 
"X-MS-DIAGNOSTICS");
                        if (diagnostics && strstr (diagnostics, "invalid_grant")) {
                                g_simple_async_result_set_error (
                                        enode->simple,
@@ -1002,19 +992,6 @@ ews_response_cb (SoupSession *session,
                goto exit;
        }
 
-       /* TODO: The stdout can be replaced with Evolution's
-        * Logging framework also */
-
-       log_level = e_ews_debug_get_log_level ();
-       if (log_level >= 1 && log_level < 3) {
-               /* This will dump only the headers, since we stole the body.
-                * And only if EWS_DEBUG=1, since higher levels will have dumped
-                * it directly from libsoup anyway. */
-               e_ews_debug_dump_raw_soup_response (msg);
-               /* And this will dump the body... */
-               e_soap_response_dump_response (response, stdout);
-       }
-
        param = e_soap_response_get_first_parameter_by_name (response, "detail", NULL);
        if (param)
                param = e_soap_parameter_get_first_child_by_name (param, "ResponseCode");
@@ -1051,7 +1028,7 @@ ews_response_cb (SoupSession *session,
                g_object_ref (msg);
 
                flag = e_flag_new ();
-               while (wait_ms > 0 && !g_cancellable_is_cancelled (cancellable) && msg->status_code != 
SOUP_STATUS_CANCELLED) {
+               while (wait_ms > 0 && !g_cancellable_is_cancelled (cancellable)) {
                        gint64 now = g_get_monotonic_time ();
                        gint left_minutes, left_seconds;
 
@@ -1088,8 +1065,7 @@ ews_response_cb (SoupSession *session,
 
                g_object_unref (response);
 
-               if (g_cancellable_is_cancelled (cancellable) ||
-                   msg->status_code == SOUP_STATUS_CANCELLED) {
+               if (g_cancellable_is_cancelled (cancellable)) {
                        g_clear_object (&cancellable);
                        g_object_unref (msg);
                } else {
@@ -1996,7 +1972,7 @@ ews_connection_constructed (GObject *object)
 
        if (log_level >= 2) {
                SoupLogger *logger;
-               logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
+               logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
 
                if (log_level >= 3) {
                        soup_logger_set_printer (logger, e_ews_soup_log_printer, NULL, NULL);
@@ -2016,10 +1992,6 @@ ews_connection_constructed (GObject *object)
        soup_session_add_feature_by_type (cnc->priv->soup_session,
                                          SOUP_TYPE_COOKIE_JAR);
 
-       g_signal_connect (
-               cnc->priv->soup_session, "authenticate",
-               G_CALLBACK (ews_connection_authenticate), cnc);
-
        e_ews_connection_utils_prepare_auth_method (cnc->priv->soup_session,
                camel_ews_settings_get_auth_mechanism (cnc->priv->settings));
 }
@@ -2056,10 +2028,6 @@ ews_connection_dispose (GObject *object)
        NOTIFICATION_UNLOCK (cnc);
 
        if (cnc->priv->soup_session) {
-               g_signal_handlers_disconnect_by_func (
-                       cnc->priv->soup_session,
-                       ews_connection_authenticate, object);
-
                g_main_loop_quit (cnc->priv->soup_loop);
                g_thread_join (cnc->priv->soup_thread);
                cnc->priv->soup_thread = NULL;
@@ -2245,18 +2213,19 @@ e_ews_connection_init (EEwsConnection *cnc)
        g_mutex_init (&cnc->priv->notification_lock);
 }
 
-static void
-ews_connection_authenticate (SoupSession *sess,
-                             SoupMessage *msg,
+static gboolean
+ews_connection_authenticate (SoupMessage *msg,
                              SoupAuth *auth,
                              gboolean retrying,
                              gpointer data)
 {
        EEwsConnection *cnc = data;
 
-       g_return_if_fail (cnc != NULL);
+       g_return_val_if_fail (cnc != NULL, TRUE);
 
-       e_ews_connection_utils_authenticate (cnc, sess, msg, auth, retrying);
+       e_ews_connection_utils_authenticate (cnc, cnc->priv->soup_session, msg, auth, retrying);
+
+       return TRUE;
 }
 
 void
@@ -3160,7 +3129,7 @@ autodiscover_response_cb (SoupSession *session,
        GSimpleAsyncResult *simple = data;
        struct _autodiscover_data *ad;
        EwsUrls exch_urls, expr_urls;
-       guint status = msg->status_code;
+       guint status = soup_message_get_status (msg);
        xmlDoc *doc;
        xmlNode *node;
        gchar *str;
@@ -3183,7 +3152,7 @@ autodiscover_response_cb (SoupSession *session,
 
        ad->msgs[idx] = NULL;
 
-       if (status != 200) {
+       if (status != SOUP_STATUS_OK) {
                gboolean expired = FALSE;
                gchar *service_url = NULL;
 
@@ -3203,7 +3172,6 @@ autodiscover_response_cb (SoupSession *session,
                goto failed;
        }
 
-       e_ews_debug_dump_raw_soup_response (msg);
        doc = xmlReadMemory (
                msg->response_body->data,
                msg->response_body->length,
@@ -3441,7 +3409,7 @@ post_restarted (SoupMessage *msg,
        xmlOutputBuffer *buf = data;
 
        /* Not all restarts are due to a redirect; some are for auth */
-       if (msg->status_code == 401)
+       if (msg->status_code == SOUP_STATUS_UNAUTHORIZED)
                return;
 
        /* In violation of RFC2616, libsoup will change a POST request to
@@ -3508,8 +3476,6 @@ e_ews_get_msg_for_url (EEwsConnection *cnc,
                        G_CALLBACK (post_restarted), buf);
        }
 
-       e_ews_debug_dump_raw_soup_request (msg);
-
        return msg;
 }
 
@@ -3553,14 +3519,14 @@ autodiscover_srv_record_resolved_cb (GObject *source,
        g_list_free_full (targets, (GDestroyNotify) g_srv_target_free);
 
        if (new_uri && success) {
-               SoupURI *suri;
+               GUri *uri;
 
-               suri = soup_uri_new (new_uri);
-               if (suri) {
-                       soup_message_set_uri (ad->msgs[5], suri);
+               uri = uri = g_uri_parse (new_uri, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+               if (uri) {
+                       soup_message_set_uri (ad->msgs[5], uri);
                        /* The autodiscover_response_cb will free the 'simple' */
                        ews_connection_schedule_queue_message (ad->cnc, ad->msgs[5], 
autodiscover_response_cb, simple);
-                       soup_uri_free (suri);
+                       g_uri_unref (uri);
                } else {
                        success = FALSE;
                }
@@ -3612,7 +3578,7 @@ e_ews_discover_prepare_messages_and_send (GSimpleAsyncResult *simple,
                                          const gchar *override_url,
                                          GError **error)
 {
-       SoupURI *soup_uri = NULL;
+       GUri *uri = NULL;
        gboolean use_secure = TRUE;
        gboolean is_outlook = FALSE;
        gchar *url1, *url2, *url3, *url4;
@@ -3651,11 +3617,11 @@ e_ews_discover_prepare_messages_and_send (GSimpleAsyncResult *simple,
        url5 = NULL;
 
        if (override_url)
-               soup_uri = soup_uri_new (override_url);
+               uri = g_uri_parse (override_url, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
 
-       if (soup_uri) {
-               const gchar *host = soup_uri_get_host (soup_uri);
-               const gchar *scheme = soup_uri_get_scheme (soup_uri);
+       if (uri) {
+               const gchar *host = g_uri_get_host (uri);
+               const gchar *scheme = g_uri_get_scheme (uri);
 
                use_secure = g_strcmp0 (scheme, "https") == 0;
 
@@ -3685,7 +3651,7 @@ e_ews_discover_prepare_messages_and_send (GSimpleAsyncResult *simple,
                        #undef ON_MICROSOFT_COM_TEXT
                }
 
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        is_outlook = is_outlook || (domain && g_ascii_strcasecmp (domain, "outlook.com") == 0);
@@ -4041,12 +4007,12 @@ oal_response_cb (SoupSession *soup_session,
 
        if (ews_connection_credentials_failed (data->cnc, soup_message, simple)) {
                goto exit;
-       } else if (soup_message->status_code != 200) {
+       } else if (soup_message->status_code != SOUP_STATUS_OK) {
                if (soup_message->status_code == SOUP_STATUS_UNAUTHORIZED &&
-                   soup_message->response_headers) {
+                   soup_message_get_response_headers (soup_message)) {
                        const gchar *diagnostics;
 
-                       diagnostics = soup_message_headers_get_list (soup_message->response_headers, 
"X-MS-DIAGNOSTICS");
+                       diagnostics = soup_message_headers_get_list (soup_message_get_response_headers 
(soup_message), "X-MS-DIAGNOSTICS");
                        if (diagnostics && strstr (diagnostics, "invalid_grant")) {
                                g_simple_async_result_set_error (
                                        simple,
@@ -4072,12 +4038,9 @@ oal_response_cb (SoupSession *soup_session,
                goto exit;
        }
 
-       etag = soup_message_headers_get_one(soup_message->response_headers,
-                                           "ETag");
+       etag = soup_message_headers_get_one (soup_message_get_response_headers (soup_message), "ETag");
        if (etag)
-               data->etag = g_strdup(etag);
-
-       e_ews_debug_dump_raw_soup_response (soup_message);
+               data->etag = g_strdup (etag);
 
        doc = xmlReadMemory (
                soup_message->response_body->data,
@@ -4318,7 +4281,7 @@ e_ews_connection_get_oal_detail (EEwsConnection *cnc,
        }
 
        if (etag && *etag)
-               soup_message_headers_append (soup_message->request_headers,
+               soup_message_headers_append (soup_message_get_request_headers (soup_message),
                                             "If-None-Match", etag);
 
        data = g_slice_new0 (struct _oal_req_data);
@@ -4396,7 +4359,7 @@ oal_download_response_cb (SoupSession *soup_session,
 
        if (ews_connection_credentials_failed (data->cnc, soup_message, simple)) {
                g_unlink (data->cache_filename);
-       } else if (soup_message->status_code != 200) {
+       } else if (soup_message->status_code != SOUP_STATUS_OK) {
                g_simple_async_result_set_error (
                        simple, SOUP_HTTP_ERROR,
                        soup_message->status_code,
@@ -4411,8 +4374,6 @@ oal_download_response_cb (SoupSession *soup_session,
                g_unlink (data->cache_filename);
        }
 
-       e_ews_debug_dump_raw_soup_response (soup_message);
-
        g_simple_async_result_complete_in_idle (simple);
        e_ews_connection_utils_unref_in_thread (simple);
 }
@@ -4424,9 +4385,7 @@ ews_soup_got_headers (SoupMessage *msg,
        struct _oal_req_data *data = (struct _oal_req_data *) user_data;
        const gchar *size;
 
-       size = soup_message_headers_get_one (
-               msg->response_headers,
-               "Content-Length");
+       size = soup_message_headers_get_one (soup_message_get_response_headers (msg), "Content-Length");
 
        if (size)
                data->response_size = strtol (size, NULL, 10);
@@ -4450,7 +4409,7 @@ ews_soup_got_chunk (SoupMessage *msg,
        struct _oal_req_data *data = (struct _oal_req_data *) user_data;
        gint fd;
 
-       if (msg->status_code != 200)
+       if (msg->status_code != SOUP_STATUS_OK)
                return;
 
        data->received_size += chunk->length;
@@ -4552,13 +4511,6 @@ e_ews_connection_download_oal_file (EEwsConnection *cnc,
        g_simple_async_result_set_op_res_gpointer (
                simple, data, (GDestroyNotify) oal_req_data_free);
 
-       /*
-        * Don't use streaming-based messages when we are loggin the traffic
-        * to generate trace files for tests
-        */
-       if (e_ews_debug_get_log_level () <= 2)
-               soup_message_body_set_accumulate (soup_message->response_body, FALSE);
-
        g_signal_connect (
                soup_message, "got-headers",
                G_CALLBACK (ews_soup_got_headers), data);
@@ -10383,7 +10335,7 @@ ews_connection_gather_auth_methods_cb (SoupMessage *message,
 
        g_return_if_fail (async_data != NULL);
 
-       auths_lst = soup_message_headers_get_list (message->response_headers, "WWW-Authenticate");
+       auths_lst = soup_message_headers_get_list (soup_message_get_response_headers (message), 
"WWW-Authenticate");
        if (!auths_lst)
                return;
 
diff --git a/src/EWS/common/e-ews-debug.c b/src/EWS/common/e-ews-debug.c
index 5a908f44..be5957ba 100644
--- a/src/EWS/common/e-ews-debug.c
+++ b/src/EWS/common/e-ews-debug.c
@@ -73,67 +73,3 @@ e_ews_debug_get_server_version_from_string (const gchar *version)
        else
                return E_EWS_EXCHANGE_FUTURE;
 }
-
-static void
-print_header (const gchar *name,
-             const gchar *value,
-             gpointer user_data)
-{
-       fprintf (user_data, "%s: %s\n", name, value);
-}
-
-static void
-e_ews_debug_dump_raw_soup_message (FILE *out,
-                                  SoupMessageHeaders *hdrs,
-                                  SoupMessageBody *body)
-{
-       if (body && soup_message_body_get_accumulate (body)) {
-               SoupBuffer *buffer;
-
-               buffer = soup_message_body_flatten (body);
-               soup_buffer_free (buffer);
-       }
-
-       /* print body */
-       fprintf (out, " =====================\n");
-       if (hdrs)
-               soup_message_headers_foreach (hdrs, print_header, out);
-       else
-               fprintf (out, " null headers\n");
-       fputc ('\n', out);
-       if (body && body->data) {
-               fputs (body->data, out);
-               fputc ('\n', out);
-       }
-       fflush (out);
-}
-
-void
-e_ews_debug_dump_raw_soup_request (SoupMessage *msg)
-{
-       gint log_level;
-
-       log_level = e_ews_debug_get_log_level ();
-       if (log_level == 1) {
-               /* print request body */
-               printf ("\n URI: %s\n", soup_uri_to_string (soup_message_get_uri (msg),
-                                                         TRUE));
-               printf (" The request headers for message %p\n", msg);
-               e_ews_debug_dump_raw_soup_message (stdout, msg->request_headers,
-                                                  msg->request_body);
-       }
-}
-
-void
-e_ews_debug_dump_raw_soup_response (SoupMessage *msg)
-{
-       gint log_level;
-
-       log_level = e_ews_debug_get_log_level ();
-       if (log_level >= 1) {
-               printf ("\n The response code: %d\n", msg->status_code);
-               printf (" The response headers for message %p\n", msg);
-               e_ews_debug_dump_raw_soup_message (stdout, msg->response_headers,
-                                                  msg->response_body);
-       }
-}
diff --git a/src/EWS/common/e-ews-debug.h b/src/EWS/common/e-ews-debug.h
index 46daf228..f95464e2 100644
--- a/src/EWS/common/e-ews-debug.h
+++ b/src/EWS/common/e-ews-debug.h
@@ -18,10 +18,6 @@ const gchar *        e_ews_connection_get_server_version_string
 EEwsServerVersion
                e_ews_debug_get_server_version_from_string
                                                        (const gchar *version);
-void           e_ews_debug_dump_raw_soup_request
-                                                       (SoupMessage *msg);
-void           e_ews_debug_dump_raw_soup_response
-                                                       (SoupMessage *msg);
 G_END_DECLS
 
 #endif /* E_EWS_DEBUG_H */
diff --git a/src/EWS/common/e-ews-message.c b/src/EWS/common/e-ews-message.c
index d840252d..897d573b 100644
--- a/src/EWS/common/e-ews-message.c
+++ b/src/EWS/common/e-ews-message.c
@@ -81,12 +81,12 @@ e_ews_message_set_user_agent_header (SoupMessage *message,
                user_agent = camel_ews_settings_dup_user_agent (settings);
 
                if (user_agent && *user_agent) {
-                       soup_message_headers_append (message->request_headers, "User-Agent", user_agent);
+                       soup_message_headers_append (soup_message_get_request_headers (message), 
"User-Agent", user_agent);
                }
 
                g_free (user_agent);
        } else {
-               soup_message_headers_append (message->request_headers, "User-Agent", "Evolution/" VERSION);
+               soup_message_headers_append (soup_message_get_request_headers (message), "User-Agent", 
"Evolution/" VERSION);
        }
 }
 
@@ -116,11 +116,11 @@ e_ews_message_new_with_header (CamelEwsSettings *settings,
        e_ews_message_attach_chunk_allocator (SOUP_MESSAGE (msg));
 
        soup_message_headers_append (
-               SOUP_MESSAGE (msg)->request_headers,
+               soup_message_get_request_headers (SOUP_MESSAGE (msg)),
                "Content-Type", "text/xml; charset=utf-8");
        e_ews_message_set_user_agent_header (SOUP_MESSAGE (msg), settings);
        soup_message_headers_append (
-               SOUP_MESSAGE (msg)->request_headers,
+               soup_message_get_request_headers (SOUP_MESSAGE (msg)),
                "Connection", "Keep-Alive");
 
        e_soap_message_start_envelope (msg);
diff --git a/src/EWS/common/e-ews-notification.c b/src/EWS/common/e-ews-notification.c
index af72893f..efffbb74 100644
--- a/src/EWS/common/e-ews-notification.c
+++ b/src/EWS/common/e-ews-notification.c
@@ -63,9 +63,8 @@ e_ews_notification_ref_connection (const EEwsNotification *notification)
        return g_weak_ref_get (&notification->priv->connection_wk);
 }
 
-static void
-ews_notification_authenticate (SoupSession *session,
-                              SoupMessage *message,
+static gboolean
+ews_notification_authenticate (SoupMessage *message,
                               SoupAuth *auth,
                               gboolean retrying,
                               gpointer data)
@@ -78,7 +77,7 @@ ews_notification_authenticate (SoupSession *session,
        cnc = e_ews_notification_ref_connection (notification);
 
        if (cnc) {
-               e_ews_connection_utils_authenticate (cnc, session, message, auth, retrying);
+               e_ews_connection_utils_authenticate (cnc, notif->priv->soup_session, message, auth, retrying);
                g_clear_object (&cnc);
        }
 }
@@ -177,11 +176,7 @@ ews_notification_dispose (GObject *object)
        if (notif->priv->cancellable != NULL)
                g_cancellable_cancel (notif->priv->cancellable);
 
-       if (notif->priv->soup_session != NULL) {
-               g_signal_handlers_disconnect_by_func (notif->priv->soup_session, 
ews_notification_authenticate, object);
-               g_clear_object (&notif->priv->soup_session);
-       }
-
+       g_clear_object (&notif->priv->soup_session);
        g_clear_object (&notif->priv->cancellable);
        g_weak_ref_set (&notif->priv->connection_wk, NULL);
 
@@ -254,15 +249,13 @@ e_ews_notification_init (EEwsNotification *notification)
                                          SOUP_TYPE_COOKIE_JAR);
 
        log_level = e_ews_debug_get_log_level ();
-       if (log_level >= 2) {
+       if (log_level > 0) {
                SoupLogger *logger;
-               logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
+               logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
 
                soup_session_add_feature (notification->priv->soup_session, SOUP_SESSION_FEATURE (logger));
                g_object_unref (logger);
        }
-
-       g_signal_connect (notification->priv->soup_session, "authenticate", G_CALLBACK 
(ews_notification_authenticate), notification);
 }
 
 static gboolean
@@ -280,7 +273,6 @@ e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
        GSList *l;
        guint event_type;
        xmlDoc *doc;
-       gint log_level = e_ews_debug_get_log_level ();
 
        g_return_val_if_fail (notification != NULL, FALSE);
        g_return_val_if_fail (notification->priv != NULL, FALSE);
@@ -348,24 +340,20 @@ e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
        e_soap_message_end_element (msg); /* StreamingSubscriptionRequest */
        e_ews_message_write_footer (msg); /* Complete the footer and print the request */
 
-       soup_message_body_set_accumulate (SOUP_MESSAGE (msg)->response_body, TRUE);
-
        if (g_cancellable_is_cancelled (cancellable)) {
                g_object_unref (msg);
                g_object_unref (cnc);
                return FALSE;
        }
 
-       if (log_level >= 1 && log_level < 3) {
-               e_ews_debug_dump_raw_soup_request (SOUP_MESSAGE (msg));
-       }
-
        if (!e_ews_connection_utils_prepare_message (cnc, notification->priv->soup_session, SOUP_MESSAGE 
(msg), cancellable)) {
                g_object_unref (msg);
                g_object_unref (cnc);
                return FALSE;
        }
 
+       g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
+
        soup_session_send_message (notification->priv->soup_session, SOUP_MESSAGE (msg));
        if (!SOUP_STATUS_IS_SUCCESSFUL (SOUP_MESSAGE (msg)->status_code)) {
                g_object_unref (msg);
@@ -380,9 +368,6 @@ e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
 
        response = e_soap_response_new_from_xmldoc (doc);
 
-       if (log_level >= 1 && log_level < 3) {
-               e_ews_debug_dump_raw_soup_response (SOUP_MESSAGE (msg));
-       }
        g_object_unref (msg);
        g_object_unref (cnc);
 
@@ -477,14 +462,14 @@ e_ews_notification_unsubscribe_folder_sync (EEwsNotification *notification,
 
        e_ews_message_write_footer (msg); /* Complete the footer and print the request */
 
-       soup_message_body_set_accumulate (SOUP_MESSAGE (msg)->response_body, TRUE);
-
        if (!e_ews_connection_utils_prepare_message (cnc, notification->priv->soup_session, SOUP_MESSAGE 
(msg), notification->priv->cancellable)) {
                g_object_unref (msg);
                g_object_unref (cnc);
                return FALSE;
        }
 
+       g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
+
        soup_session_send_message (notification->priv->soup_session, SOUP_MESSAGE (msg));
        if (!SOUP_STATUS_IS_SUCCESSFUL (SOUP_MESSAGE (msg)->status_code)) {
                g_object_unref (msg);
@@ -696,7 +681,6 @@ ews_notification_soup_got_chunk (SoupMessage *msg,
        const gchar *chunk_str;
        gsize chunk_len;
        gboolean keep_parsing = TRUE;
-       gint log_level = e_ews_debug_get_log_level ();
 
        /*
         * Here we receive, in chunks, "well-formed" messages that contain:
@@ -740,11 +724,6 @@ ews_notification_soup_got_chunk (SoupMessage *msg,
                if (response == NULL)
                        break;
 
-               if (log_level >= 1 && log_level < 3) {
-                       e_ews_debug_dump_raw_soup_response (msg);
-                       e_soap_response_dump_response (response, stdout);
-               }
-
                if (!ews_notification_fire_events_from_response (notification, response)) {
                        ews_notification_schedule_abort (notification->priv->soup_session);
 
@@ -871,9 +850,6 @@ e_ews_notification_get_events_sync (EEwsNotification *notification,
 
        e_ews_message_write_footer (msg); /* Complete the footer and print the request */
 
-       if (e_ews_debug_get_log_level () <= 2)
-               soup_message_body_set_accumulate (SOUP_MESSAGE (msg)->response_body, FALSE);
-
        handler_id = g_signal_connect (
                SOUP_MESSAGE (msg), "got-chunk",
                G_CALLBACK (ews_notification_soup_got_chunk), notification);
@@ -890,6 +866,8 @@ e_ews_notification_get_events_sync (EEwsNotification *notification,
        cancel_handler_id = g_cancellable_connect (cancellable, G_CALLBACK (ews_notification_cancelled_cb),
                notifcation_cancel_data_new (notification->priv->soup_session, SOUP_MESSAGE (msg)), 
notifcation_cancel_data_free);
 
+       g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
+
        if (g_cancellable_is_cancelled (cancellable))
                status_code = SOUP_STATUS_CANCELLED;
        else
diff --git a/src/EWS/common/e-oauth2-service-office365.c b/src/EWS/common/e-oauth2-service-office365.c
index 5cfd14bf..2971008c 100644
--- a/src/EWS/common/e-oauth2-service-office365.c
+++ b/src/EWS/common/e-oauth2-service-office365.c
@@ -377,7 +377,7 @@ eos_office365_extract_authorization_code (EOAuth2Service *service,
                                          const gchar *page_content,
                                          gchar **out_authorization_code)
 {
-       SoupURI *suri;
+       GUri *uri;
        gboolean known = FALSE;
 
        g_return_val_if_fail (out_authorization_code != NULL, FALSE);
@@ -387,12 +387,12 @@ eos_office365_extract_authorization_code (EOAuth2Service *service,
        if (!page_uri || !*page_uri)
                return FALSE;
 
-       suri = soup_uri_new (page_uri);
-       if (!suri)
+       uri = g_uri_parse (page_uri, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+       if (!uri)
                return FALSE;
 
-       if (suri->query) {
-               GHashTable *uri_query = soup_form_decode (suri->query);
+       if (g_uri_get_query (uri)) {
+               GHashTable *uri_query = soup_form_decode (g_uri_get_query (uri));
 
                if (uri_query) {
                        const gchar *code;
@@ -420,7 +420,7 @@ eos_office365_extract_authorization_code (EOAuth2Service *service,
                }
        }
 
-       soup_uri_free (suri);
+       g_uri_unref (uri);
 
        return known;
 }
diff --git a/src/EWS/common/e-soup-auth-negotiate.c b/src/EWS/common/e-soup-auth-negotiate.c
index 5948869a..547fe1a6 100644
--- a/src/EWS/common/e-soup-auth-negotiate.c
+++ b/src/EWS/common/e-soup-auth-negotiate.c
@@ -126,7 +126,7 @@ e_soup_auth_negotiate_message_finished (SoupMessage *msg, gpointer user_data)
 
        auth = g_weak_ref_get (weak_ref);
 
-       if (auth && msg->status_code == 200 &&
+       if (auth && msg->status_code == SOUP_STATUS_OK &&
            e_soup_auth_negotiate_update (auth, msg, NULL))
                e_soup_auth_negotiate_is_ready (auth, msg);
 
@@ -185,8 +185,7 @@ e_soup_auth_negotiate_update (SoupAuth *auth, SoupMessage *msg,
         * Negotiate challenge doesn't fit the standard so it must be extracted
         * from the msg instead.
         */
-       auths_lst = soup_message_headers_get_list (msg->response_headers,
-                                                  "WWW-Authenticate");
+       auths_lst = soup_message_headers_get_list (soup_message_get_response_headers (msg), 
"WWW-Authenticate");
        if (!auths_lst)
                return FALSE;
 
@@ -216,11 +215,12 @@ e_soup_auth_negotiate_update (SoupAuth *auth, SoupMessage *msg,
 }
 
 static GSList *
-e_soup_auth_negotiate_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
+e_soup_auth_negotiate_get_protection_space (SoupAuth *auth,
+                                           GUri *source_uri)
 {
        gchar *space, *p;
 
-       space = g_strdup (source_uri->path);
+       space = g_strdup (g_uri_get_path (source_uri));
 
        /* Strip filename component */
        p = strrchr (space, '/');
@@ -247,8 +247,8 @@ e_soup_auth_negotiate_is_ready (SoupAuth *auth, SoupMessage *msg)
 
                if (!state->auth_started) {
                        CamelSasl *gssapi_sasl;
-                       SoupURI *soup_uri;
-                       char const *host;
+                       GUri *uri;
+                       const gchar *host;
 
                        gssapi_sasl = g_object_new (
                                camel_sasl_gssapi_get_type (),
@@ -256,8 +256,8 @@ e_soup_auth_negotiate_is_ready (SoupAuth *auth, SoupMessage *msg)
                                "service-name", "HTTP",
                                NULL);
 
-                       soup_uri = soup_message_get_uri (msg);
-                       host = soup_uri_get_host (soup_uri);
+                       uri = soup_message_get_uri (msg);
+                       host = g_uri_get_host (uri);
 
                        /* We are required to pass a username, but it doesn't
                           ever get used since we're not actually doing SASL
diff --git a/src/EWS/evolution/e-ews-config-lookup.c b/src/EWS/evolution/e-ews-config-lookup.c
index 1b28295a..29f647ed 100644
--- a/src/EWS/evolution/e-ews-config-lookup.c
+++ b/src/EWS/evolution/e-ews-config-lookup.c
@@ -195,11 +195,11 @@ ews_config_lookup_worker_result_from_data (EConfigLookup *config_lookup,
                EConfigLookupResult *lookup_result;
                GString *description;
                const gchar *extension_name;
-               SoupURI *suri;
+               GUri *uri;
 
                extension_name = e_source_camel_get_extension_name ("ews");
 
-               suri = soup_uri_new (hosturl);
+               uri = g_uri_parse (hosturl, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
 
                description = g_string_new ("");
 
@@ -247,23 +247,23 @@ ews_config_lookup_worker_result_from_data (EConfigLookup *config_lookup,
                                "user", email_address);
                }
 
-               if (suri && suri->host && *suri->host) {
+               if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
                        e_config_lookup_result_simple_add_string (lookup_result,
                                E_SOURCE_EXTENSION_AUTHENTICATION,
-                               "host", suri->host);
+                               "host", g_uri_get_host (uri));
                }
 
-               if (suri && suri->port) {
+               if (uri && g_uri_get_port (uri)) {
                        e_config_lookup_result_simple_add_uint (lookup_result,
                                E_SOURCE_EXTENSION_AUTHENTICATION,
-                               "port", suri->port);
+                               "port", g_uri_get_port (uri));
                }
 
                e_config_lookup_add_result (config_lookup, lookup_result);
 
                g_string_free (description, TRUE);
-               if (suri)
-                       soup_uri_free (suri);
+               if (uri)
+                       g_uri_unref (uri);
        }
 }
 
@@ -372,14 +372,14 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
                        ews_config_lookup_worker_result_from_settings (lookup_worker, config_lookup, 
email_address, ews_settings, params);
                } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) {
                        const gchar *hosturl;
-                       SoupURI *suri;
+                       GUri *uri;
 
                        hosturl = camel_ews_settings_get_hosturl (ews_settings);
-                       suri = soup_uri_new (hosturl);
-                       if (suri) {
-                               certificate_host = g_strdup (soup_uri_get_host (suri));
+                       uri = g_uri_parse (hosturl, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+                       if (uri) {
+                               certificate_host = g_strdup (g_uri_get_host (uri));
 
-                               soup_uri_free (suri);
+                               g_uri_unref (suri);
                        }
                } else {
                        g_clear_error (&local_error);
@@ -408,14 +408,14 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
                                        ews_config_lookup_worker_result_from_settings (lookup_worker, 
config_lookup, email_address, ews_settings, params);
                                } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, 
SOUP_STATUS_SSL_FAILED)) {
                                        const gchar *hosturl;
-                                       SoupURI *suri;
+                                       GUri *uri;
 
                                        hosturl = camel_ews_settings_get_hosturl (ews_settings);
-                                       suri = soup_uri_new (hosturl);
-                                       if (suri) {
-                                               certificate_host = g_strdup (soup_uri_get_host (suri));
+                                       uri = g_uri_parse (hosturl, SOUP_HTTP_URI_FLAGS | 
G_URI_FLAGS_PARSE_RELAXED, NULL);
+                                       if (uri) {
+                                               certificate_host = g_strdup (g_uri_get_host (uri));
 
-                                               soup_uri_free (suri);
+                                               g_uri_unref (uri);
                                        }
                                } else {
                                        g_clear_error (&local_error);
diff --git a/src/EWS/evolution/e-mail-config-ews-backend.c b/src/EWS/evolution/e-mail-config-ews-backend.c
index be5380c9..d792f8d4 100644
--- a/src/EWS/evolution/e-mail-config-ews-backend.c
+++ b/src/EWS/evolution/e-mail-config-ews-backend.c
@@ -724,11 +724,11 @@ mail_config_ews_backend_check_complete (EMailConfigServiceBackend *backend)
        complete = complete && correct;
 
        if (correct) {
-               SoupURI *suri;
+               GUri *uri;
 
-               suri = soup_uri_new (hosturl);
-               if (suri) {
-                       soup_uri_free (suri);
+               uri = g_uri_parse (hosturl, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+               if (uri) {
+                       g_uri_unref (uri);
                        e_util_set_entry_issue_hint (ews_backend->priv->host_entry, NULL);
                } else {
                        e_util_set_entry_issue_hint (ews_backend->priv->host_entry, _("Host URL is not 
valid"));
@@ -739,11 +739,11 @@ mail_config_ews_backend_check_complete (EMailConfigServiceBackend *backend)
        }
 
        if (oaburl && *oaburl) {
-               SoupURI *suri;
+               GUri *uri;
 
-               suri = soup_uri_new (oaburl);
-               if (suri) {
-                       soup_uri_free (suri);
+               uri = g_uri_parse (oaburl, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+               if (uri) {
+                       g_uri_unref (uri);
                        e_util_set_entry_issue_hint (ews_backend->priv->oab_entry, NULL);
                } else {
                        e_util_set_entry_issue_hint (ews_backend->priv->oab_entry, _("OAB URL is not valid"));
diff --git a/src/EWS/registry/e-ews-backend.c b/src/EWS/registry/e-ews-backend.c
index 26ce2e9f..3a89e930 100644
--- a/src/EWS/registry/e-ews-backend.c
+++ b/src/EWS/registry/e-ews-backend.c
@@ -1125,7 +1125,7 @@ ews_backend_get_destination_address (EBackend *backend,
                                     guint16 *port)
 {
        CamelEwsSettings *ews_settings;
-       SoupURI *soup_uri;
+       GUri *uri;
        gchar *host_url;
        gboolean result = FALSE;
 
@@ -1138,10 +1138,10 @@ ews_backend_get_destination_address (EBackend *backend,
        host_url = camel_ews_settings_dup_hosturl (ews_settings);
        g_return_val_if_fail (host_url != NULL, FALSE);
 
-       soup_uri = soup_uri_new (host_url);
-       if (soup_uri) {
-               *host = g_strdup (soup_uri_get_host (soup_uri));
-               *port = soup_uri_get_port (soup_uri);
+       uri = g_uri_parse (host_url, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+       if (uri) {
+               *host = g_strdup (g_uri_get_host (uri));
+               *port = g_uri_get_port (uri);
 
                result = *host && **host;
                if (!result) {
@@ -1149,7 +1149,7 @@ ews_backend_get_destination_address (EBackend *backend,
                        *host = NULL;
                }
 
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        g_free (host_url);
diff --git a/src/Microsoft365/camel/camel-m365-folder.c b/src/Microsoft365/camel/camel-m365-folder.c
index 2db2b366..14a97604 100644
--- a/src/Microsoft365/camel/camel-m365-folder.c
+++ b/src/Microsoft365/camel/camel-m365-folder.c
@@ -391,10 +391,10 @@ m365_folder_download_message_cb (EM365Connection *cnc,
        g_return_val_if_fail (CAMEL_IS_STREAM (cache_stream), FALSE);
        g_return_val_if_fail (G_IS_INPUT_STREAM (raw_data_stream), FALSE);
 
-       if (message && message->response_headers) {
+       if (message && soup_message_get_response_headers (message)) {
                const gchar *content_length_str;
 
-               content_length_str = soup_message_headers_get_one (message->response_headers, 
"Content-Length");
+               content_length_str = soup_message_headers_get_one (soup_message_get_response_headers 
(message), "Content-Length");
 
                if (content_length_str && *content_length_str)
                        expected_size = (gssize) g_ascii_strtoll (content_length_str, NULL, 10);
diff --git a/src/Microsoft365/common/e-m365-connection.c b/src/Microsoft365/common/e-m365-connection.c
index e81d06ed..14f24cb8 100644
--- a/src/Microsoft365/common/e-m365-connection.c
+++ b/src/Microsoft365/common/e-m365-connection.c
@@ -101,7 +101,7 @@ m365_connection_utils_ensure_bearer_auth_usage (SoupSession *session,
 {
        SoupAuthManager *auth_manager;
        SoupSessionFeature *feature;
-       SoupURI *soup_uri;
+       GUri *uri;
 
        g_return_if_fail (SOUP_IS_SESSION (session));
 
@@ -116,23 +116,30 @@ m365_connection_utils_ensure_bearer_auth_usage (SoupSession *session,
                soup_session_feature_add_feature (feature, E_TYPE_SOUP_AUTH_BEARER);
        }
 
-       soup_uri = message ? soup_message_get_uri (message) : NULL;
-       if (soup_uri && soup_uri->host && *soup_uri->host) {
-               soup_uri = soup_uri_copy_host (soup_uri);
+       uri = message ? soup_message_get_uri (message) : NULL;
+       if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
+               uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
+                       g_uri_get_scheme (uri),
+                       NULL /* userinfo */,
+                       g_uri_get_host (uri),
+                       g_uri_get_port (uri),
+                       NULL /* path */,
+                       NULL /* query */,
+                       NULL /* fragment */);
        } else {
-               soup_uri = NULL;
+               uri = NULL;
        }
 
-       g_return_if_fail (soup_uri != NULL);
+       g_return_if_fail (uri != NULL);
 
        auth_manager = SOUP_AUTH_MANAGER (feature);
 
        /* This will make sure the 'bearer' is used regardless of the current 'auth_manager' state.
           See https://gitlab.gnome.org/GNOME/libsoup/-/issues/196 for more information. */
        soup_auth_manager_clear_cached_credentials (auth_manager);
-       soup_auth_manager_use_auth (auth_manager, soup_uri, SOUP_AUTH (bearer));
+       soup_auth_manager_use_auth (auth_manager, uri, SOUP_AUTH (bearer));
 
-       soup_uri_free (soup_uri);
+       g_uri_unref (uri);
 }
 
 static gboolean
@@ -200,30 +207,37 @@ m365_connection_utils_prepare_bearer_auth (EM365Connection *cnc,
                g_clear_object (&using_bearer_auth);
        } else {
                SoupAuth *soup_auth;
-               SoupURI *soup_uri;
-
-               soup_uri = message ? soup_message_get_uri (message) : NULL;
-               if (soup_uri && soup_uri->host && *soup_uri->host) {
-                       soup_uri = soup_uri_copy_host (soup_uri);
+               GUri *uri;
+
+               uri = message ? soup_message_get_uri (message) : NULL;
+               if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
+                       uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
+                               g_uri_get_scheme (uri),
+                               NULL /* userinfo */,
+                               g_uri_get_host (uri),
+                               g_uri_get_port (uri),
+                               NULL /* path */,
+                               NULL /* query */,
+                               NULL /* fragment */);
                } else {
-                       soup_uri = NULL;
+                       uri = NULL;
                }
 
-               g_warn_if_fail (soup_uri != NULL);
+               g_warn_if_fail (uri != NULL);
 
-               if (!soup_uri) {
+               if (!uri) {
                        soup_message_set_status_full (message, SOUP_STATUS_MALFORMED, "Cannot get host from 
message");
                        return FALSE;
                }
 
-               soup_auth = g_object_new (E_TYPE_SOUP_AUTH_BEARER, SOUP_AUTH_HOST, soup_uri->host, NULL);
+               soup_auth = g_object_new (E_TYPE_SOUP_AUTH_BEARER, SOUP_AUTH_HOST, g_uri_get_host (uri), 
NULL);
 
                success = m365_connection_utils_setup_bearer_auth (cnc, session, message, FALSE, 
E_SOUP_AUTH_BEARER (soup_auth), cancellable, &local_error);
                if (success)
                        e_m365_connection_set_bearer_auth (cnc, E_SOUP_AUTH_BEARER (soup_auth));
 
                g_object_unref (soup_auth);
-               soup_uri_free (soup_uri);
+               g_uri_unref (uri);
        }
 
        if (!success) {
@@ -241,9 +255,8 @@ m365_connection_utils_prepare_bearer_auth (EM365Connection *cnc,
        return success;
 }
 
-static void
-m365_connection_authenticate (SoupSession *session,
-                             SoupMessage *msg,
+static gboolean
+m365_connection_authenticate (SoupMessage *msg,
                              SoupAuth *auth,
                              gboolean retrying,
                              gpointer user_data)
@@ -252,7 +265,7 @@ m365_connection_authenticate (SoupSession *session,
        ESoupAuthBearer *using_bearer_auth;
        GError *local_error = NULL;
 
-       g_return_if_fail (E_IS_M365_CONNECTION (cnc));
+       g_return_val_if_fail (E_IS_M365_CONNECTION (cnc), TRUE);
 
        using_bearer_auth = e_m365_connection_ref_bearer_auth (cnc);
 
@@ -268,16 +281,18 @@ m365_connection_authenticate (SoupSession *session,
 
        if (!using_bearer_auth) {
                g_warn_if_reached ();
-               return;
+               return TRUE;
        }
 
-       m365_connection_utils_setup_bearer_auth (cnc, session, msg, TRUE, E_SOUP_AUTH_BEARER (auth), NULL, 
&local_error);
+       m365_connection_utils_setup_bearer_auth (cnc, cnc->priv->soup_session, msg, TRUE, E_SOUP_AUTH_BEARER 
(auth), NULL, &local_error);
 
        if (local_error)
                soup_message_set_status_full (msg, SOUP_STATUS_IO_ERROR, local_error->message);
 
        g_object_unref (using_bearer_auth);
        g_clear_error (&local_error);
+
+       return TRUE;
 }
 
 static gboolean
@@ -294,6 +309,12 @@ m365_connection_utils_prepare_message (EM365Connection *cnc,
        if (source)
                e_soup_ssl_trust_connect (message, source);
 
+       if (!g_signal_handler_find (message, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, 
m365_connection_authenticate, cnc)) {
+               g_signal_connect (
+                       message, "authenticate",
+                       G_CALLBACK (m365_connection_authenticate), cnc);
+       }
+
        if (!m365_connection_utils_prepare_bearer_auth (cnc, session, message, cancellable))
                return FALSE;
 
@@ -516,7 +537,7 @@ m365_connection_constructed (GObject *object)
        G_OBJECT_CLASS (e_m365_connection_parent_class)->constructed (object);
 
        if (m365_log_enabled ()) {
-               SoupLogger *logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
+               SoupLogger *logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
 
                soup_session_add_feature (cnc->priv->soup_session, SOUP_SESSION_FEATURE (logger));
 
@@ -527,10 +548,6 @@ m365_connection_constructed (GObject *object)
        soup_session_add_feature_by_type (cnc->priv->soup_session, E_TYPE_SOUP_AUTH_BEARER);
        soup_session_remove_feature_by_type (cnc->priv->soup_session, SOUP_TYPE_AUTH_BASIC);
 
-       g_signal_connect (
-               cnc->priv->soup_session, "authenticate",
-               G_CALLBACK (m365_connection_authenticate), cnc);
-
        cnc->priv->hash_key = camel_network_settings_dup_user (CAMEL_NETWORK_SETTINGS (cnc->priv->settings));
 
        if (!cnc->priv->hash_key)
@@ -538,7 +555,7 @@ m365_connection_constructed (GObject *object)
 
        e_binding_bind_property (
                cnc->priv->settings, "timeout",
-               cnc->priv->soup_session, SOUP_SESSION_TIMEOUT,
+               cnc->priv->soup_session, "timeout",
                G_BINDING_SYNC_CREATE);
 }
 
@@ -701,9 +718,7 @@ e_m365_connection_init (EM365Connection *cnc)
 
        cnc->priv->backoff_for_usec = 0;
        cnc->priv->soup_session = soup_session_new_with_options (
-               SOUP_SESSION_TIMEOUT, 90,
-               SOUP_SESSION_SSL_STRICT, TRUE,
-               SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
+               "timeout", 90,
                NULL);
 
        /* Do not use G_BINDING_SYNC_CREATE, because we don't have a GProxyResolver yet anyway. */
@@ -1082,7 +1097,8 @@ e_m365_connection_json_node_from_message (SoupMessage *message,
        } else {
                const gchar *content_type;
 
-               content_type = message->response_headers ? soup_message_headers_get_content_type 
(message->response_headers, NULL) : NULL;
+               content_type = soup_message_get_response_headers (message) ?
+                       soup_message_headers_get_content_type (soup_message_get_response_headers (message), 
NULL) : NULL;
 
                if (content_type && g_ascii_strcasecmp (content_type, "application/json") == 0) {
                        JsonParser *json_parser;
@@ -1145,7 +1161,7 @@ m365_connection_send_request_sync (EM365Connection *cnc,
        g_return_val_if_fail (response_func != NULL || raw_data_func != NULL, FALSE);
        g_return_val_if_fail (response_func == NULL || raw_data_func == NULL, FALSE);
 
-       while (need_retry && !g_cancellable_is_cancelled (cancellable) && message->status_code != 
SOUP_STATUS_CANCELLED) {
+       while (need_retry && !g_cancellable_is_cancelled (cancellable)) {
                need_retry = FALSE;
 
                LOCK (cnc);
@@ -1166,7 +1182,7 @@ m365_connection_send_request_sync (EM365Connection *cnc,
                                        flag, NULL);
                        }
 
-                       while (wait_ms > 0 && !g_cancellable_is_cancelled (cancellable) && 
message->status_code != SOUP_STATUS_CANCELLED) {
+                       while (wait_ms > 0 && !g_cancellable_is_cancelled (cancellable)) {
                                gint64 now = g_get_monotonic_time ();
                                gint left_minutes, left_seconds;
 
@@ -1250,7 +1266,8 @@ m365_connection_send_request_sync (EM365Connection *cnc,
                                const gchar *retry_after_str;
                                gint64 retry_after;
 
-                               retry_after_str = message->response_headers ? soup_message_headers_get_one 
(message->response_headers, "Retry-After") : NULL;
+                               retry_after_str = soup_message_get_response_headers (message) ?
+                                       soup_message_headers_get_one (soup_message_get_response_headers 
(message), "Retry-After") : NULL;
 
                                if (retry_after_str && *retry_after_str)
                                        retry_after = g_ascii_strtoll (retry_after_str, NULL, 10);
@@ -1286,18 +1303,18 @@ m365_connection_send_request_sync (EM365Connection *cnc,
                                        success = response_func && response_func (cnc, message, input_stream, 
node, func_user_data, &next_link, cancellable, error);
 
                                        if (success && next_link && *next_link) {
-                                               SoupURI *suri;
+                                               GUri *uri;
 
-                                               suri = soup_uri_new (next_link);
+                                               uri = g_uri_parse (next_link, SOUP_HTTP_URI_FLAGS | 
G_URI_FLAGS_PARSE_RELAXED, NULL);
 
                                                /* Check whether the server returned correct nextLink URI */
-                                               g_warn_if_fail (suri != NULL);
+                                               g_warn_if_fail (uri != NULL);
 
-                                               if (suri) {
+                                               if (uri) {
                                                        need_retry = TRUE;
 
-                                                       soup_message_set_uri (message, suri);
-                                                       soup_uri_free (suri);
+                                                       soup_message_set_uri (message, uri);
+                                                       g_uri_unref (uri);
                                                }
                                        }
 
@@ -1382,7 +1399,7 @@ e_m365_read_to_byte_array_cb (EM365Connection *cnc,
        if (!*out_byte_array) {
                goffset content_length;
 
-               content_length = soup_message_headers_get_content_length (message->response_headers);
+               content_length = soup_message_headers_get_content_length (soup_message_get_response_headers 
(message));
 
                if (!content_length || content_length > 65536)
                        content_length = 65535;
@@ -1508,15 +1525,17 @@ m365_connection_new_soup_message (const gchar *method,
        message = soup_message_new (method, uri);
 
        if (message) {
-               soup_message_headers_append (message->request_headers, "Connection", "Close");
-               soup_message_headers_append (message->request_headers, "User-Agent", "Evolution-M365/" 
VERSION);
+               SoupMessageHeaders *request_headers = soup_message_get_request_headers (message);
+
+               soup_message_headers_append (request_headers, "Connection", "Close");
+               soup_message_headers_append (request_headers, "User-Agent", "Evolution-M365/" VERSION);
 
                /* Disable caching for proxies (RFC 4918, section 10.4.5) */
-               soup_message_headers_append (message->request_headers, "Cache-Control", "no-cache");
-               soup_message_headers_append (message->request_headers, "Pragma", "no-cache");
+               soup_message_headers_append (request_headers, "Cache-Control", "no-cache");
+               soup_message_headers_append (request_headers, "Pragma", "no-cache");
 
                if ((csm_flags & CSM_DISABLE_RESPONSE) != 0)
-                       soup_message_headers_append (message->request_headers, "Prefer", "return=minimal");
+                       soup_message_headers_append (request_headers, "Prefer", "return=minimal");
        } else {
                g_set_error (error, SOUP_HTTP_ERROR, SOUP_STATUS_MALFORMED, _("Malformed URI: ā€œ%sā€"), uri);
        }
@@ -1807,10 +1826,10 @@ e_m365_connection_set_json_body (SoupMessage *message,
 
        data = json_generator_to_data (generator, &data_length);
 
-       soup_message_headers_set_content_type (message->request_headers, "application/json", NULL);
+       soup_message_headers_set_content_type (soup_message_get_request_headers (message), 
"application/json", NULL);
 
        if (data)
-               soup_message_body_append_take (message->request_body, (guchar *) data, data_length);
+               e_soup_session_util_set_message_request_body_from_data (message, FALSE, "application/json", 
data, data_length, g_free);
 
        g_object_unref (generator);
        json_node_unref (node);
@@ -1834,7 +1853,7 @@ e_m365_fill_message_headers_cb (JsonObject *object,
                value = json_node_get_string (member_node);
 
                if (value)
-                       soup_message_headers_replace (message->response_headers, member_name, value);
+                       soup_message_headers_replace (soup_message_get_response_headers (message), 
member_name, value);
        }
 }
 
@@ -1958,7 +1977,9 @@ e_m365_connection_batch_request_internal_sync (EM365Connection *cnc,
        for (ii = 0; success && ii < requests->len; ii++) {
                SoupMessageHeadersIter iter;
                SoupMessage *submessage;
-               SoupURI *suri;
+               GUri *guri;
+               GInputStream *request_body;
+               gssize request_body_length = 0;
                gboolean has_headers = FALSE;
                const gchar *hdr_name, *hdr_value, *use_uri;
                gboolean is_application_json = FALSE;
@@ -1970,8 +1991,8 @@ e_m365_connection_batch_request_internal_sync (EM365Connection *cnc,
 
                submessage->status_code = SOUP_STATUS_IO_ERROR;
 
-               suri = soup_message_get_uri (submessage);
-               uri = suri ? soup_uri_to_string (suri, TRUE) : NULL;
+               guri = soup_message_get_uri (submessage);
+               uri = guri ? g_uri_to_string_partial (guri, G_URI_HIDE_PASSWORD) : NULL;
 
                if (!uri) {
                        submessage->status_code = SOUP_STATUS_MALFORMED;
@@ -1995,7 +2016,7 @@ e_m365_connection_batch_request_internal_sync (EM365Connection *cnc,
 
                g_free (uri);
 
-               soup_message_headers_iter_init (&iter, submessage->request_headers);
+               soup_message_headers_iter_init (&iter, soup_message_get_request_headers (submessage));
 
                while (soup_message_headers_iter_next (&iter, &hdr_name, &hdr_value)) {
                        if (hdr_name && *hdr_name && hdr_value &&
@@ -2018,39 +2039,52 @@ e_m365_connection_batch_request_internal_sync (EM365Connection *cnc,
                if (has_headers)
                        e_m365_json_end_object_member (builder); /* headers */
 
-               if (submessage->request_body) {
-                       SoupBuffer *sbuffer;
+               request_body = e_soup_session_util_get_message_request_body (submessage, 
&request_body_length);
 
-                       sbuffer = soup_message_body_flatten (submessage->request_body);
+               if (request_body && request_body_length > 0) {
+                       if (is_application_json) {
+                               /* The server needs it unpacked, not as a plain string */
+                               JsonParser *parser;
+                               JsonNode *node;
 
-                       if (sbuffer && sbuffer->length > 0) {
-                               if (is_application_json) {
-                                       /* The server needs it unpacked, not as a plain string */
-                                       JsonParser *parser;
-                                       JsonNode *node;
+                               parser = json_parser_new_immutable ();
 
-                                       parser = json_parser_new_immutable ();
+                               success = json_parser_load_from_stream (parser, request_body, error);
 
-                                       success = json_parser_load_from_data (parser, sbuffer->data, 
sbuffer->length, error);
+                               if (!success)
+                                       g_prefix_error (error, "%s", _("Failed to parse own Json data"));
 
-                                       if (!success)
-                                               g_prefix_error (error, "%s", _("Failed to parse own Json 
data"));
+                               node = success ? json_parser_steal_root (parser) : NULL;
 
-                                       node = success ? json_parser_steal_root (parser) : NULL;
+                               if (node) {
+                                       json_builder_set_member_name (builder, "body");
+                                       json_builder_add_value (builder, node);
+                               }
 
-                                       if (node) {
-                                               json_builder_set_member_name (builder, "body");
-                                               json_builder_add_value (builder, node);
-                                       }
+                               g_clear_object (&parser);
+                       } else {
+                               GByteArray *array;
+                               guint8 *buffer;
+                               gsize n_buffer_sz = 16384;
+                               gsize n_read;
 
-                                       g_clear_object (&parser);
-                               } else {
-                                       e_m365_json_add_string_member (builder, "body", sbuffer->data);
+                               buffer = g_new0 (guint8, n_buffer_sz);
+                               array = g_byte_array_sized_new (request_body_length + 1);
+
+                               while (g_input_stream_read_all (request_body, buffer, n_buffer_sz, &n_read, 
cancellable, NULL))) {
+                                       if (n_read > 0)
+                                               g_byte_array_append (array, buffer, n_read);
                                }
-                       }
 
-                       if (sbuffer)
-                               soup_buffer_free (sbuffer);
+                               /* null-terminate the data, to use it as a string */
+                               buffer[0] = '\0';
+                               g_byte_array_append (array, buffer, 1);
+
+                               e_m365_json_add_string_member (builder, "body", array->data);
+
+                               g_byte_array_unref (array);
+                               g_free (buffer);
+                       }
                }
 
                e_m365_json_end_object_member (builder); /* unnamed object */
@@ -2061,7 +2095,7 @@ e_m365_connection_batch_request_internal_sync (EM365Connection *cnc,
 
        e_m365_connection_set_json_body (message, builder);
 
-       soup_message_headers_append (message->request_headers, "Accept", "application/json");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Accept", 
"application/json");
 
        g_object_unref (builder);
 
@@ -2124,7 +2158,8 @@ e_m365_connection_batch_request_sync (EM365Connection *cnc,
 
                                        g_ptr_array_add (new_requests, message);
 
-                                       retry_after_str = message->response_headers ? 
soup_message_headers_get_one (message->response_headers, "Retry-After") : NULL;
+                                       retry_after_str = soup_message_get_response_headers (message) ?
+                                               soup_message_headers_get_one 
(soup_message_get_response_headers (message), "Retry-After") : NULL;
 
                                        if (retry_after_str && *retry_after_str)
                                                retry_after = g_ascii_strtoll (retry_after_str, NULL, 10);
@@ -2345,7 +2380,7 @@ e_m365_connection_get_folders_delta_sync (EM365Connection *cnc,
 
                prefer_value = g_strdup_printf ("odata.maxpagesize=%u", max_page_size);
 
-               soup_message_headers_append (message->request_headers, "Prefer", prefer_value);
+               soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
prefer_value);
 
                g_free (prefer_value);
        }
@@ -2676,7 +2711,7 @@ e_m365_connection_get_objects_delta_sync (EM365Connection *cnc,
 
                prefer_value = g_strdup_printf ("odata.maxpagesize=%u", max_page_size);
 
-               soup_message_headers_append (message->request_headers, "Prefer", prefer_value);
+               soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
prefer_value);
 
                g_free (prefer_value);
        }
@@ -3220,7 +3255,7 @@ e_m365_connection_send_mail_message_sync (EM365Connection *cnc,
 
        g_free (uri);
 
-       soup_message_headers_append (message->request_headers, "Content-Length", "0");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Content-Length", "0");
 
        success = m365_connection_send_request_sync (cnc, message, NULL, e_m365_read_no_response_cb, NULL, 
cancellable, error);
 
@@ -3390,11 +3425,11 @@ e_m365_connection_update_contact_photo_sync (EM365Connection *cnc,
 
        g_free (uri);
 
-       soup_message_headers_set_content_type (message->request_headers, "image/jpeg", NULL);
-       soup_message_headers_set_content_length (message->request_headers, jpeg_photo ? jpeg_photo->len : 0);
+       soup_message_headers_set_content_type (soup_message_get_request_headers (message), "image/jpeg", 
NULL);
+       soup_message_headers_set_content_length (soup_message_get_request_headers (message), jpeg_photo ? 
jpeg_photo->len : 0);
 
        if (jpeg_photo)
-               soup_message_body_append (message->request_body, SOUP_MEMORY_STATIC, jpeg_photo->data, 
jpeg_photo->len);
+               e_soup_session_util_set_message_request_body_from_data (message, FALSE, "image/jpeg", 
jpeg_photo->data, jpeg_photo->len, NULL);
 
        success = m365_connection_send_request_sync (cnc, message, NULL, e_m365_read_no_response_cb, NULL, 
cancellable, error);
 
@@ -4082,7 +4117,7 @@ m365_connection_prefer_outlook_timezone (SoupMessage *message,
 
                prefer_value = g_strdup_printf ("outlook.timezone=\"%s\"", prefer_outlook_timezone);
 
-               soup_message_headers_append (message->request_headers, "Prefer", prefer_value);
+               soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
prefer_value);
 
                g_free (prefer_value);
        }
@@ -4131,7 +4166,7 @@ e_m365_connection_list_events_sync (EM365Connection *cnc,
 
        m365_connection_prefer_outlook_timezone (message, prefer_outlook_timezone);
 
-       soup_message_headers_append (message->request_headers, "Prefer", 
"outlook.body-content-type=\"text\"");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
"outlook.body-content-type=\"text\"");
 
        memset (&rd, 0, sizeof (EM365ResponseData));
 
@@ -4233,7 +4268,7 @@ e_m365_connection_prepare_get_event (EM365Connection *cnc,
        g_free (uri);
 
        m365_connection_prefer_outlook_timezone (message, prefer_outlook_timezone);
-       soup_message_headers_append (message->request_headers, "Prefer", 
"outlook.body-content-type=\"text\"");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
"outlook.body-content-type=\"text\"");
 
        return message;
 }
@@ -5397,7 +5432,7 @@ e_m365_connection_list_tasks_sync (EM365Connection *cnc,
        g_free (uri);
 
        m365_connection_prefer_outlook_timezone (message, prefer_outlook_timezone);
-       soup_message_headers_append (message->request_headers, "Prefer", 
"outlook.body-content-type=\"text\"");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
"outlook.body-content-type=\"text\"");
 
        memset (&rd, 0, sizeof (EM365ResponseData));
 
@@ -5500,7 +5535,7 @@ e_m365_connection_prepare_get_task (EM365Connection *cnc,
        g_free (uri);
 
        m365_connection_prefer_outlook_timezone (message, prefer_outlook_timezone);
-       soup_message_headers_append (message->request_headers, "Prefer", 
"outlook.body-content-type=\"text\"");
+       soup_message_headers_append (soup_message_get_request_headers (message), "Prefer", 
"outlook.body-content-type=\"text\"");
 
        return message;
 }
diff --git a/src/Microsoft365/common/e-oauth2-service-microsoft365.c 
b/src/Microsoft365/common/e-oauth2-service-microsoft365.c
index 5440dd24..3b51384c 100644
--- a/src/Microsoft365/common/e-oauth2-service-microsoft365.c
+++ b/src/Microsoft365/common/e-oauth2-service-microsoft365.c
@@ -333,7 +333,7 @@ eos_microsoft365_extract_authorization_code (EOAuth2Service *service,
                                             const gchar *page_content,
                                             gchar **out_authorization_code)
 {
-       SoupURI *suri;
+       GUri *uri;
        gboolean known = FALSE;
 
        g_return_val_if_fail (out_authorization_code != NULL, FALSE);
@@ -343,12 +343,12 @@ eos_microsoft365_extract_authorization_code (EOAuth2Service *service,
        if (!page_uri || !*page_uri)
                return FALSE;
 
-       suri = soup_uri_new (page_uri);
-       if (!suri)
+       uri = g_uri_parse (page_uri, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+       if (!uri)
                return FALSE;
 
-       if (suri->query) {
-               GHashTable *uri_query = soup_form_decode (suri->query);
+       if (g_uri_get_query (uri)) {
+               GHashTable *uri_query = soup_form_decode (g_uri_get_query (uri));
 
                if (uri_query) {
                        const gchar *code;
@@ -376,7 +376,7 @@ eos_microsoft365_extract_authorization_code (EOAuth2Service *service,
                }
        }
 
-       soup_uri_free (suri);
+       g_uri_unref (uri);
 
        return known;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]