soup-client-input-stream: emit SoupMessage::got-chunk
authorSergio Villar Senin <svillar@igalia.com>
Tue, 24 Apr 2012 16:49:58 +0000 (18:49 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 25 Apr 2012 06:18:27 +0000 (08:18 +0200)
SoupClientInputStream will emit the got-chunk signal whenever data is read
from the stream. With that hack we keep the SoupCache working while it is
not proprely migrated to the new gio-based architecture.

https://bugzilla.gnome.org/show_bug.cgi?id=674732

libsoup/soup-client-input-stream.c

index 8d1a2ea..99b3093 100644 (file)
@@ -80,6 +80,17 @@ get_property (GObject *object, guint prop_id,
        }
 }
 
+/* Temporary HACK to keep SoupCache working. See soup_client_input_stream_read_fn()
+ * and soup_client_input_stream_read_nonblocking().
+ */
+static void
+soup_client_input_stream_emit_got_chunk (SoupClientInputStream *stream, void *data, gssize nread)
+{
+       SoupBuffer *buffer = soup_buffer_new (SOUP_MEMORY_TEMPORARY, data, nread);
+       soup_message_got_chunk (stream->priv->msg, buffer);
+       soup_buffer_free (buffer);
+}
+
 static gssize
 soup_client_input_stream_read_fn (GInputStream  *stream,
                                  void          *buffer,
@@ -95,6 +106,12 @@ soup_client_input_stream_read_fn (GInputStream  *stream,
        if (nread == 0)
                g_signal_emit (stream, signals[EOF], 0);
 
+       /* Temporary HACK to keep SoupCache working */
+       if (nread > 0) {
+               soup_client_input_stream_emit_got_chunk (SOUP_CLIENT_INPUT_STREAM (stream),
+                                                        buffer, nread);
+       }
+
        return nread;
 }
 
@@ -112,6 +129,12 @@ soup_client_input_stream_read_nonblocking (GPollableInputStream  *stream,
        if (nread == 0)
                g_signal_emit (stream, signals[EOF], 0);
 
+       /* Temporary HACK to keep SoupCache working */
+       if (nread > 0) {
+               soup_client_input_stream_emit_got_chunk (SOUP_CLIENT_INPUT_STREAM (stream),
+                                                        buffer, nread);
+       }
+
        return nread;
 }