diff options
author | Dan Winship <danw@src.gnome.org> | 2009-01-29 18:40:24 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2009-01-29 18:40:24 +0000 |
commit | 2c3134c14a9eee2916e53eda3f99ef40065fc1cd (patch) | |
tree | 3925cfef3542e8c1110d67908f55326c33163b06 /libsoup/soup-message-body.c | |
parent | 6343c5a70b0590c2e57b1407696305d74163ded9 (diff) | |
download | libsoup-2c3134c14a9eee2916e53eda3f99ef40065fc1cd.tar.gz |
Fix this; previously it would discard the entire message body after
* libsoup/soup-message-body.c (soup_message_body_wrote_chunk): Fix
this; previously it would discard the entire message body after
writing a SOUP_MEMORY_TEMPORARY chunk. Part of WebKit bug 18343.
* libsoup/soup-message-io.c (io_write): use
io->write_chunk->length *before* freeing io->write_chunk.
* tests/chunk-test.c (do_temporary_test): new test to make sure
that TEMPORARY buffers are handled properly.
svn path=/trunk/; revision=1232
Diffstat (limited to 'libsoup/soup-message-body.c')
-rw-r--r-- | libsoup/soup-message-body.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libsoup/soup-message-body.c b/libsoup/soup-message-body.c index f83b883f..c95f84d5 100644 --- a/libsoup/soup-message-body.c +++ b/libsoup/soup-message-body.c @@ -593,15 +593,16 @@ soup_message_body_got_chunk (SoupMessageBody *body, SoupBuffer *chunk) /** * soup_message_body_wrote_chunk: * @body: a #SoupMessageBody - * @chunk: a #SoupBuffer received from the network + * @chunk: a #SoupBuffer returned from soup_message_body_get_chunk() * * Handles the #SoupMessageBody part of writing a chunk of data to the * network. Normally this is a no-op, but if you have set @body's - * accumulate flag to %FALSE, then this will cause @chunk (and any - * chunks preceding it in @body) to be discarded to free up memory. + * accumulate flag to %FALSE, then this will cause @chunk to be + * discarded to free up memory. * - * This is a low-level method which you should not normally need to - * use. + * This is a low-level method which you should not need to use, and + * there are further restrictions on its proper use which are not + * documented here. **/ void soup_message_body_wrote_chunk (SoupMessageBody *body, SoupBuffer *chunk) @@ -612,15 +613,16 @@ soup_message_body_wrote_chunk (SoupMessageBody *body, SoupBuffer *chunk) if (priv->accumulate) return; - do { - chunk2 = priv->chunks->data; - priv->chunks = g_slist_remove (priv->chunks, chunk2); - priv->base_offset += chunk2->length; - soup_buffer_free (chunk2); - } while (priv->chunks && chunk2 != chunk); + chunk2 = priv->chunks->data; + g_return_if_fail (chunk->length == chunk2->length); + g_return_if_fail (chunk == chunk2 || ((SoupBufferPrivate *)chunk2)->use == SOUP_MEMORY_TEMPORARY); + priv->chunks = g_slist_remove (priv->chunks, chunk2); if (!priv->chunks) priv->last = NULL; + + priv->base_offset += chunk2->length; + soup_buffer_free (chunk2); } static SoupMessageBody * |