[evolution-ews/gnome-41] Retry on Unauthorized response when server disconnected



commit 99d6fe309b5ba051300e1018c4f12d98373f31b0
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 27 11:02:18 2022 +0100

    Retry on Unauthorized response when server disconnected
    
    When a server disconnects before the request is sent and libsoup
    sends it without the Authorization header, then retry when the server
    responds with 401 Unauthorized, instead of asking the used for
    the password.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-ews/-/issues/174

 src/EWS/common/e-ews-connection.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/EWS/common/e-ews-connection.c b/src/EWS/common/e-ews-connection.c
index 621826ea..7ab46b37 100644
--- a/src/EWS/common/e-ews-connection.c
+++ b/src/EWS/common/e-ews-connection.c
@@ -31,6 +31,7 @@
 #define d(x) x
 
 #define EWS_RETRY_IO_ERROR_SECONDS 3
+#define EWS_RETRY_AUTH_ERROR_SECONDS 0.1
 
 /* A chunk size limit when moving items in chunks. */
 #define EWS_MOVE_ITEMS_CHUNK_SIZE 500
@@ -955,6 +956,14 @@ ews_response_cb (SoupSession *session,
                        "%s", msg->reason_phrase);
                goto exit;
        } else if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) {
+               /* This can happen when the server terminated the connection before the request started */
+               if (!enode->retrying_after_network_error &&
+                   !soup_message_headers_get_one (msg->request_headers, "Authorization")) {
+                       wait_ms = EWS_RETRY_AUTH_ERROR_SECONDS * 1000;
+                       enode->retrying_after_network_error = TRUE;
+                       goto retrylbl;
+               }
+
                if (msg->response_headers) {
                        const gchar *diagnostics;
 


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