[shotwell] When logging SOUP requests, skip binary data



commit 9bb23e04cec4dfed18f933cc6c9e12e7b7e7731b
Author: Jens Georg <mail jensge org>
Date:   Sat Sep 10 18:07:20 2022 +0200

    When logging SOUP requests, skip binary data

 plugins/common/RESTSupport.vala | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index cddedf4a..e65afead 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -38,6 +38,15 @@ public abstract class Session {
         this.endpoint_url = endpoint_url;
         soup_session = new Soup.Session ();
         if (Environment.get_variable("SHOTWELL_SOUP_LOG") != null) {
+            var logger = new Soup.Logger(Soup.LoggerLogLevel.BODY);
+            logger.set_request_filter((logger, msg) => {
+                var content_type = msg.get_request_headers().get_content_type(null);
+                if (content_type != null && content_type == "application/octet-stream") {
+                    return Soup.LoggerLogLevel.HEADERS;
+                }
+
+                return Soup.LoggerLogLevel.BODY;
+            });
             soup_session.add_feature (new Soup.Logger (Soup.LoggerLogLevel.BODY));
         }
     }


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