diff options
author | Dan Winship <danw@gnome.org> | 2010-01-23 10:40:22 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2010-01-23 10:40:22 -0500 |
commit | f9181c7ad0b65b5798cf11dca2f1479e79661731 (patch) | |
tree | d3a69e065cdeb0c99962dbba9000165349e51da2 /tests | |
parent | ff425f5cd44d8ffd0d9ce29e5117995d0ec8ce86 (diff) | |
download | libsoup-f9181c7ad0b65b5798cf11dca2f1479e79661731.tar.gz libsoup-f9181c7ad0b65b5798cf11dca2f1479e79661731.tar.bz2 libsoup-f9181c7ad0b65b5798cf11dca2f1479e79661731.zip |
[SoupCodingGzip] discard trailing junk after decoding, for compatibility
https://bugzilla.gnome.org/show_bug.cgi?id=606352
Diffstat (limited to 'tests')
-rw-r--r-- | tests/coding-test.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/coding-test.c b/tests/coding-test.c index 47efb4a2..e0dae157 100644 --- a/tests/coding-test.c +++ b/tests/coding-test.c @@ -26,7 +26,7 @@ server_callback (SoupServer *server, SoupMessage *msg, const char *path, GHashTable *query, SoupClientContext *context, gpointer data) { - const char *accept_encoding; + const char *accept_encoding, *junk; GSList *codings; char *file = NULL, *contents; gsize length; @@ -64,13 +64,20 @@ server_callback (SoupServer *server, SoupMessage *msg, soup_message_set_status (msg, SOUP_STATUS_OK); soup_message_body_append (msg->response_body, SOUP_MEMORY_TAKE, contents, length); + + junk = soup_message_headers_get_one (msg->request_headers, + "X-Trailing-Junk"); + if (junk) { + soup_message_body_append (msg->response_body, SOUP_MEMORY_COPY, + junk, strlen (junk)); + } } static void do_coding_test (void) { SoupSession *session; - SoupMessage *msg, *msgz; + SoupMessage *msg, *msgz, *msgj; SoupURI *uri; const char *coding; @@ -124,12 +131,46 @@ do_coding_test (void) } else if (memcmp (msg->response_body->data, msgz->response_body->data, msg->response_body->length) != 0) { - debug_printf (1, " Message data mismatch\n"); + debug_printf (1, " Message data mismatch (plain/compressed)\n"); + errors++; + } + + debug_printf (1, "GET /mbox, Accept-Encoding: gzip, plus trailing junk\n"); + msgj = soup_message_new_from_uri ("GET", uri); + soup_message_headers_append (msgj->request_headers, + "X-Trailing-Junk", "junk!"); + soup_session_send_message (session, msgj); + if (!SOUP_STATUS_IS_SUCCESSFUL (msgj->status_code)) { + debug_printf (1, " Unexpected status %d %s\n", + msgj->status_code, msgj->reason_phrase); + errors++; + } + coding = soup_message_headers_get_one (msgj->response_headers, "Content-Encoding"); + if (!coding || g_ascii_strcasecmp (coding, "gzip") != 0) { + debug_printf (1, " Unexpected Content-Encoding: %s\n", + coding ? coding : "(none)"); + errors++; + } + if (!(soup_message_get_flags (msgj) & SOUP_MESSAGE_CONTENT_DECODED)) { + debug_printf (1, " SOUP_MESSAGE_CONTENT_DECODED not set!\n"); + errors++; + } + + if (msg->response_body->length != msgj->response_body->length) { + debug_printf (1, " Message length mismatch: %lu (plain) vs %lu (compressed w/ junk)\n", + (gulong)msg->response_body->length, + (gulong)msgj->response_body->length); + errors++; + } else if (memcmp (msg->response_body->data, + msgj->response_body->data, + msg->response_body->length) != 0) { + debug_printf (1, " Message data mismatch (plain/compressed w/ junk)\n"); errors++; } g_object_unref (msg); g_object_unref (msgz); + g_object_unref (msgj); soup_uri_free (uri); soup_test_session_abort_unref (session); |