summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-08-25 16:45:21 -0400
committerDan Winship <danw@gnome.org>2013-08-25 17:06:27 -0400
commit6d149d8595d93c706c816a22acaffef37ea34ca5 (patch)
tree34827b2291f0cb7be63ac72faa8b7789fb73f4e2
parenta7ce33ef264e0794fa1e406a879607018cfc6597 (diff)
downloadlibsoup-6d149d8595d93c706c816a22acaffef37ea34ca5.tar.gz
soup-filter-input-stream: fix read_until() with subclasses
If doing a read_line()/read_until() in a subclass, we need to use the subclass's read implementation rather than just going directly to the base stream.
-rw-r--r--libsoup/soup-filter-input-stream.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/libsoup/soup-filter-input-stream.c b/libsoup/soup-filter-input-stream.c
index 3b76386b..8067b882 100644
--- a/libsoup/soup-filter-input-stream.c
+++ b/libsoup/soup-filter-input-stream.c
@@ -23,6 +23,7 @@
struct _SoupFilterInputStreamPrivate {
GByteArray *buf;
gboolean need_more;
+ gboolean in_read_until;
};
static void soup_filter_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface, gpointer interface_data);
@@ -79,8 +80,10 @@ soup_filter_input_stream_read_fn (GInputStream *stream,
{
SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (stream);
- fstream->priv->need_more = FALSE;
- if (fstream->priv->buf) {
+ if (!fstream->priv->in_read_until)
+ fstream->priv->need_more = FALSE;
+
+ if (fstream->priv->buf && !fstream->priv->in_read_until) {
return read_from_buf (fstream, buffer, count);
} else {
return g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
@@ -108,8 +111,10 @@ soup_filter_input_stream_read_nonblocking (GPollableInputStream *stream,
{
SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (stream);
- fstream->priv->need_more = FALSE;
- if (fstream->priv->buf) {
+ if (!fstream->priv->in_read_until)
+ fstream->priv->need_more = FALSE;
+
+ if (fstream->priv->buf && !fstream->priv->in_read_until) {
return read_from_buf (fstream, buffer, count);
} else {
return g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
@@ -217,10 +222,12 @@ soup_filter_input_stream_read_until (SoupFilterInputStream *fstream,
g_byte_array_set_size (fstream->priv->buf, length);
buf = fstream->priv->buf->data;
- nread = g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
+ fstream->priv->in_read_until = TRUE;
+ nread = g_pollable_stream_read (G_INPUT_STREAM (fstream),
buf + prev_len, length - prev_len,
blocking,
cancellable, &my_error);
+ fstream->priv->in_read_until = FALSE;
if (nread <= 0) {
if (prev_len)
fstream->priv->buf->len = prev_len;