[evolution-data-server] I#215 - Utilize If-None-Match header for WebCal refresh



commit 2e8e24debf5e9fab62321ac86771efc4ab1d42c4
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jul 2 11:39:11 2020 +0200

    I#215 - Utilize If-None-Match header for WebCal refresh
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/215

 src/calendar/backends/http/e-cal-backend-http.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/calendar/backends/http/e-cal-backend-http.c b/src/calendar/backends/http/e-cal-backend-http.c
index ea0cd42ef..5f633a8ed 100644
--- a/src/calendar/backends/http/e-cal-backend-http.c
+++ b/src/calendar/backends/http/e-cal-backend-http.c
@@ -240,11 +240,22 @@ ecb_http_connect_sync (ECalMetaBackend *meta_backend,
 
                message = soup_request_http_get_message (request);
 
+               if (message) {
+                       gchar *last_etag;
+
+                       last_etag = e_cal_meta_backend_dup_sync_tag (meta_backend);
+
+                       if (last_etag && *last_etag)
+                               soup_message_headers_append (message->request_headers, "If-None-Match", 
last_etag);
+
+                       g_free (last_etag);
+               }
+
                input_stream = e_soup_session_send_request_sync (cbhttp->priv->session, request, cancellable, 
&local_error);
 
                success = input_stream != NULL;
 
-               if (success && message && !SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
+               if (success && message && !SOUP_STATUS_IS_SUCCESSFUL (message->status_code) && 
message->status_code != SOUP_STATUS_NOT_MODIFIED) {
                        if (input_stream && e_soup_session_get_log_level (cbhttp->priv->session) == 
SOUP_LOGGER_LOG_BODY) {
                                gchar *response = ecb_http_read_stream_sync (input_stream, -1, cancellable, 
NULL);
 
@@ -410,6 +421,15 @@ ecb_http_get_changes_sync (ECalMetaBackend *meta_backend,
        if (message) {
                const gchar *new_etag;
 
+               if (message->status_code == SOUP_STATUS_NOT_MODIFIED) {
+                       g_rec_mutex_unlock (&cbhttp->priv->conn_lock);
+                       g_object_unref (message);
+
+                       ecb_http_disconnect_sync (meta_backend, cancellable, NULL);
+
+                       return TRUE;
+               }
+
                new_etag = soup_message_headers_get_one (message->response_headers, "ETag");
                if (new_etag && !*new_etag) {
                        new_etag = NULL;


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