[libsoup] logger: Don't treat max-body-size of 0 as unlimited



commit 620affbcad1a10727ee229a678c351b52880e250
Author: Patrick Griffis <pgriffis igalia com>
Date:   Mon Jan 10 18:21:34 2022 -0600

    logger: Don't treat max-body-size of 0 as unlimited
    
    Also fix default value of -1 not being set.
    
    Closes #259

 libsoup/soup-logger.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index 944676e7..9f6f080c 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -163,14 +163,13 @@ write_body (SoupLogger *logger, const char *buffer, gsize nread,
             g_hash_table_insert (bodies, key, body);
         }
 
-        if (priv->max_body_size > 0) {
+        if (priv->max_body_size >= 0) {
                 /* longer than max => we've written the extra [...] */
                 if (body->len > priv->max_body_size)
                         return;
                 int cap = priv->max_body_size - body->len;
-                if (cap)
-                        g_string_append_len (body, buffer,
-                                             (nread < cap) ? nread : cap);
+                if (cap > 0)
+                        g_string_append_len (body, buffer, MIN (nread, cap));
                 if (nread > cap)
                         g_string_append (body, "\n[...]");
         } else {
@@ -368,6 +367,7 @@ soup_logger_class_init (SoupLoggerClass *logger_class)
                                    -1,
                                    G_MAXINT,
                                    -1,
+                                   G_PARAM_CONSTRUCT |
                                    G_PARAM_READWRITE |
                                    G_PARAM_STATIC_STRINGS);
 


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