[libsoup] Actually test chunked encoding, and fix some hangs
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Subject: [libsoup] Actually test chunked encoding, and fix some hangs
- Date: Fri, 10 Jul 2009 14:47:39 +0000 (UTC)
commit 2c0d924c6808b20540a76d0d2e9c266dc441b862
Author: Gustavo Noronha Silva <gustavo noronha collabora co uk>
Date: Fri Jul 10 14:29:28 2009 +0100
Actually test chunked encoding, and fix some hangs
The test was not really testing chunked encoding, because of incorrect
handling of the query string in the SoupURI, now it does. This has
exposed a couple hangs.
This change also avoids hanging on chunked encoding messages on the
sniffing test by calling soup_message_body_complete(), and by
sanitizing IO read state and read_length inconditionally when we reach
got_body, during message IO.
libsoup/soup-message-io.c | 18 ++++++++----------
tests/sniffing-test.c | 9 ++++++++-
2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 10657b7..5951e98 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -866,6 +866,14 @@ io_read (SoupSocket *sock, SoupMessage *msg)
return;
got_body:
+ /* If we end up returning, read_state needs to be set
+ * to IO_STATE_BODY, and read_length must be 0; since
+ * we may be coming from STATE_TRAILERS, or may be
+ * doing a read-to-eof, we sanitize these here.
+ */
+ io->read_state = SOUP_MESSAGE_IO_STATE_BODY;
+ io->read_length = 0;
+
/* A chunk of data may have been read and the emission
* of got_chunk delayed because we wanted to wait for
* more chunks to arrive, for doing content sniffing,
@@ -885,16 +893,6 @@ io_read (SoupSocket *sock, SoupMessage *msg)
soup_buffer_free (sniffed_buffer);
soup_message_body_free (io->delayed_chunk_data);
io->delayed_chunk_data = NULL;
-
- /* If we end up returning, read_state
- * needs to be set to IO_STATE_BODY,
- * and read_length must be 0; since we
- * may be coming from STATE_TRAILERS,
- * or may be doing a read-to-eof, we
- * sanitize these here.
- */
- io->read_state = SOUP_MESSAGE_IO_STATE_BODY;
- io->read_length = 0;
SOUP_MESSAGE_IO_RETURN_IF_CANCELLED_OR_PAUSED;
}
}
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index ad2690f..6cf6a03 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -24,6 +24,7 @@ server_callback (SoupServer *server, SoupMessage *msg,
char *chunked;
char *contents;
gsize length;
+ gboolean use_chunked_encoding = FALSE;
if (msg->method != SOUP_METHOD_GET) {
soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
@@ -34,9 +35,11 @@ server_callback (SoupServer *server, SoupMessage *msg,
if (query) {
chunked = g_hash_table_lookup (query, "chunked");
- if (chunked && g_str_equal (chunked, "yes"))
+ if (chunked && g_str_equal (chunked, "yes")) {
soup_message_headers_set_encoding (msg->response_headers,
SOUP_ENCODING_CHUNKED);
+ use_chunked_encoding = TRUE;
+ }
}
if (!strcmp (path, "/mbox")) {
@@ -160,6 +163,8 @@ server_callback (SoupServer *server, SoupMessage *msg,
"Content-Type", "text/plain");
}
+ if (use_chunked_encoding)
+ soup_message_body_complete (msg->response_body);
}
static gboolean
@@ -245,6 +250,8 @@ do_signals_test (gboolean should_content_sniff,
if (chunked_encoding)
soup_uri_set_query (uri, "chunked=yes");
+ soup_message_set_uri (msg, uri);
+
soup_message_body_set_accumulate (msg->response_body, should_accumulate);
g_object_connect (msg,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]