summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gustavo.noronha@collabora.co.uk>2009-07-10 14:29:28 +0100
committerGustavo Noronha Silva <gns@gnome.org>2009-07-10 15:47:11 +0100
commit2c0d924c6808b20540a76d0d2e9c266dc441b862 (patch)
tree9b80ed5a1df9bcbf94c201ee1fe81404590b6c7e
parentaad40ac467d12a188aed01e543aef5016aa4d3cb (diff)
downloadlibsoup-2c0d924c6808b20540a76d0d2e9c266dc441b862.tar.gz
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.
-rw-r--r--libsoup/soup-message-io.c18
-rw-r--r--tests/sniffing-test.c9
2 files changed, 16 insertions, 11 deletions
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 10657b7e..5951e989 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 ad2690f9..6cf6a03a 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,