soup-session.c: do not emit content-sniffed if it isn't cached
authorSergio Villar Senin <svillar@igalia.com>
Tue, 19 Feb 2013 14:44:17 +0000 (15:44 +0100)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 19 Feb 2013 14:48:14 +0000 (15:48 +0100)
The SoupCache does not get any information from sniffed content types as it
works at a lower level. That's why sometimes we might not have any
Content-Type information for a cached resource (if the server does not
specify it).

libsoup/soup-session.c

index ab13ca9..b0fc1d5 100644 (file)
@@ -3764,13 +3764,15 @@ async_return_from_cache (SoupMessageQueueItem *item,
                         GInputStream         *stream)
 {
        const char *content_type;
-       GHashTable *params;
+       GHashTable *params = NULL;
 
        soup_message_got_headers (item->msg);
 
        content_type = soup_message_headers_get_content_type (item->msg->response_headers, &params);
-       soup_message_content_sniffed (item->msg, content_type, params);
-       g_hash_table_unref (params);
+       if (content_type) {
+               soup_message_content_sniffed (item->msg, content_type, params);
+               g_hash_table_unref (params);
+       }
 
        item->state = SOUP_MESSAGE_FINISHING;
        async_send_request_return_result (item, g_object_ref (stream), NULL);