[libsoup/carlosgc/message-flags: 6/7] message: remove SOUP_MESSAGE_CONTENT_DECODED flag




commit dc66f1d3ab4b9a81a55f80a282db5620f6e3c54c
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Fri Nov 6 14:06:01 2020 +0100

    message: remove SOUP_MESSAGE_CONTENT_DECODED flag
    
    Flags are expected to be set by the user to modify the behavior of a
    message, not by libsoup to notify the user.

 libsoup/content-sniffer/soup-content-decoder.c   |  7 ++---
 libsoup/content-sniffer/soup-converter-wrapper.c |  6 +----
 libsoup/soup-message.c                           |  7 -----
 libsoup/soup-message.h                           |  9 +++----
 tests/coding-test.c                              | 34 +++++++-----------------
 5 files changed, 17 insertions(+), 46 deletions(-)
---
diff --git a/libsoup/content-sniffer/soup-content-decoder.c b/libsoup/content-sniffer/soup-content-decoder.c
index 99a0210f..5be8cc38 100644
--- a/libsoup/content-sniffer/soup-content-decoder.c
+++ b/libsoup/content-sniffer/soup-content-decoder.c
@@ -35,16 +35,13 @@
  * soup_session_add_feature() or soup_session_add_feature_by_type().
  *
  * If #SoupContentDecoder successfully decodes the Content-Encoding,
- * it will set the %SOUP_MESSAGE_CONTENT_DECODED flag on the message,
- * and the message body and the chunks in the #SoupMessage::got_chunk
- * signals will contain the decoded data; however, the message headers
+ * the message body will contain the decoded data; however, the message headers
  * will be unchanged (and so "Content-Encoding" will still be present,
  * "Content-Length" will describe the original encoded length, etc).
  *
  * If "Content-Encoding" contains any encoding types that
  * #SoupContentDecoder doesn't recognize, then none of the encodings
- * will be decoded (and the %SOUP_MESSAGE_CONTENT_DECODED flag will
- * not be set).
+ * will be decoded.
  *
  * (Note that currently there is no way to (automatically) use
  * Content-Encoding when sending a request body, or to pick specific
diff --git a/libsoup/content-sniffer/soup-converter-wrapper.c 
b/libsoup/content-sniffer/soup-converter-wrapper.c
index b84e4a02..f669ee55 100644
--- a/libsoup/content-sniffer/soup-converter-wrapper.c
+++ b/libsoup/content-sniffer/soup-converter-wrapper.c
@@ -24,8 +24,6 @@
  * at an arbitrary point rather than containing a complete compressed
  * representation.
  *
- * If the wrapped conversion succeeds, then the wrapper will set the
- * %SOUP_MESSAGE_CONTENT_DECODED flag on its message.
  */
 
 enum {
@@ -249,10 +247,8 @@ soup_converter_wrapper_real_convert (GConverter *converter,
                                      flags, bytes_read, bytes_written,
                                      &my_error);
        if (result != G_CONVERTER_ERROR) {
-               if (!priv->started) {
-                       soup_message_add_flags (priv->msg, SOUP_MESSAGE_CONTENT_DECODED);
+               if (!priv->started)
                        priv->started = TRUE;
-               }
 
                if (result == G_CONVERTER_FINISHED &&
                    !(flags & G_CONVERTER_INPUT_AT_END)) {
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index f969fe2d..809731ee 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -1320,8 +1320,6 @@ soup_message_cleanup_response (SoupMessage *msg)
 
        soup_message_headers_clear (priv->response_headers);
 
-       priv->msg_flags &= ~SOUP_MESSAGE_CONTENT_DECODED;
-
        priv->status_code = SOUP_STATUS_NONE;
        if (priv->reason_phrase) {
                g_free (priv->reason_phrase);
@@ -1332,7 +1330,6 @@ soup_message_cleanup_response (SoupMessage *msg)
        g_object_notify (G_OBJECT (msg), "status-code");
        g_object_notify (G_OBJECT (msg), "reason-phrase");
        g_object_notify (G_OBJECT (msg), "http-version");
-       g_object_notify (G_OBJECT (msg), "flags");
        g_object_notify (G_OBJECT (msg), "tls-certificate");
        g_object_notify (G_OBJECT (msg), "tls-certificate-errors");
 }
@@ -1341,10 +1338,6 @@ soup_message_cleanup_response (SoupMessage *msg)
  * SoupMessageFlags:
  * @SOUP_MESSAGE_NO_REDIRECT: The session should not follow redirect
  *   (3xx) responses received by this message.
- * @SOUP_MESSAGE_CONTENT_DECODED: Set by #SoupContentDecoder to
- *   indicate that it has removed the Content-Encoding on a message (and
- *   so headers such as Content-Length may no longer accurately describe
- *   the body).
  * @SOUP_MESSAGE_NEW_CONNECTION: Requests that the message should be
  *   sent on a newly-created connection, not reusing an existing
  *   persistent connection. Note that messages with non-idempotent
diff --git a/libsoup/soup-message.h b/libsoup/soup-message.h
index 0e2abc1a..36094843 100644
--- a/libsoup/soup-message.h
+++ b/libsoup/soup-message.h
@@ -75,11 +75,10 @@ gboolean         soup_message_get_is_top_level_navigation (SoupMessage      *msg
 
 typedef enum {
        SOUP_MESSAGE_NO_REDIRECT              = (1 << 1),
-       SOUP_MESSAGE_CONTENT_DECODED          = (1 << 2),
-       SOUP_MESSAGE_NEW_CONNECTION           = (1 << 3),
-       SOUP_MESSAGE_IDEMPOTENT               = (1 << 4),
-       SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS = (1 << 5),
-       SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE    = (1 << 6)
+       SOUP_MESSAGE_NEW_CONNECTION           = (1 << 2),
+       SOUP_MESSAGE_IDEMPOTENT               = (1 << 3),
+       SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS = (1 << 4),
+       SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE    = (1 << 5)
 } SoupMessageFlags;
 
 SOUP_AVAILABLE_IN_2_4
diff --git a/tests/coding-test.c b/tests/coding-test.c
index 7162a2b3..d25dbd0d 100644
--- a/tests/coding-test.c
+++ b/tests/coding-test.c
@@ -137,17 +137,10 @@ typedef enum {
        CODING_TEST_EMPTY       = (1 << 1)
 } CodingTestType;
 
-typedef enum {
-       NO_CHECK,
-       EXPECT_DECODED,
-       EXPECT_NOT_DECODED
-} MessageContentStatus;
-
 static void
 check_response (CodingTestData *data,
                const char *expected_encoding,
                const char *expected_content_type,
-               MessageContentStatus status,
                GBytes *body)
 {
        const char *coding, *type;
@@ -157,13 +150,6 @@ check_response (CodingTestData *data,
        coding = soup_message_headers_get_one (soup_message_get_response_headers (data->msg), 
"Content-Encoding");
        g_assert_cmpstr (coding, ==, expected_encoding);
 
-       if (status != NO_CHECK) {
-               if (status == EXPECT_DECODED)
-                       g_assert_true (soup_message_get_flags (data->msg) & SOUP_MESSAGE_CONTENT_DECODED);
-               else
-                       g_assert_false (soup_message_get_flags (data->msg) & SOUP_MESSAGE_CONTENT_DECODED);
-       }
-
        type = soup_message_headers_get_one (soup_message_get_response_headers (data->msg), "Content-Type");
        g_assert_cmpstr (type, ==, expected_content_type);
 
@@ -211,7 +197,7 @@ do_coding_test_plain (CodingTestData *data, gconstpointer test_data)
        GBytes *body;
 
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, NULL, "text/plain", EXPECT_NOT_DECODED, body);
+       check_response (data, NULL, "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -221,7 +207,7 @@ do_coding_test_gzip (CodingTestData *data, gconstpointer test_data)
        GBytes *body;
 
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "gzip", "text/plain", EXPECT_DECODED, body);
+       check_response (data, "gzip", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -237,7 +223,7 @@ do_coding_test_gzip_with_junk (CodingTestData *data, gconstpointer test_data)
                                     "X-Test-Options", "trailing-junk");
 
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "gzip", "text/plain", EXPECT_DECODED, body);
+       check_response (data, "gzip", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -257,7 +243,7 @@ do_coding_test_gzip_bad_server (CodingTestData *data, gconstpointer test_data)
         * from what the server sent... which happens to be the
         * uncompressed data.
         */
-       check_response (data, "gzip", "text/plain", EXPECT_NOT_DECODED, body);
+       check_response (data, "gzip", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -269,7 +255,7 @@ do_coding_test_deflate (CodingTestData *data, gconstpointer test_data)
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "prefer-deflate-zlib");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "deflate", "text/plain", EXPECT_DECODED, body);
+       check_response (data, "deflate", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -284,7 +270,7 @@ do_coding_test_deflate_with_junk (CodingTestData *data, gconstpointer test_data)
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "prefer-deflate-zlib, trailing-junk");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "deflate", "text/plain", EXPECT_DECODED, body);
+       check_response (data, "deflate", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -298,7 +284,7 @@ do_coding_test_deflate_bad_server (CodingTestData *data, gconstpointer test_data
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "force-encode, prefer-deflate-zlib");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "deflate", "text/plain", EXPECT_NOT_DECODED, body);
+       check_response (data, "deflate", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -310,7 +296,7 @@ do_coding_test_deflate_raw (CodingTestData *data, gconstpointer test_data)
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "prefer-deflate-raw");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "deflate", "text/plain", EXPECT_DECODED, body);
+       check_response (data, "deflate", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -324,7 +310,7 @@ do_coding_test_deflate_raw_bad_server (CodingTestData *data, gconstpointer test_
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "force-encode, prefer-deflate-raw");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "deflate", "text/plain", EXPECT_NOT_DECODED, body);
+       check_response (data, "deflate", "text/plain", body);
        g_bytes_unref (body);
 }
 
@@ -338,7 +324,7 @@ do_coding_msg_empty_test (CodingTestData *data, gconstpointer test_data)
        soup_message_headers_append (soup_message_get_request_headers (data->msg),
                                     "X-Test-Options", "empty");
        body = soup_test_session_send (data->session, data->msg, NULL, NULL);
-       check_response (data, "gzip", "text/plain", EXPECT_NOT_DECODED, body);
+       check_response (data, "gzip", "text/plain", body);
        g_bytes_unref (body);
 }
 


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