summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2021-12-20 11:33:56 +0100
committerCarlos Garcia Campos <cgarcia@igalia.com>2021-12-20 11:33:56 +0100
commit183a36b7dbd22b6d58ba7f58c006ffc600131c35 (patch)
tree3b6e2ba11378b1e024664c077346aa121e0d7aa0
parent9b2435c42870636b0007129cdb1f40a2c66eaacb (diff)
downloadlibsoup-183a36b7dbd22b6d58ba7f58c006ffc600131c35.tar.gz
http2: check status of pending messages after a read IO error
Fixes #256
-rw-r--r--libsoup/http2/soup-client-message-io-http2.c6
-rwxr-xr-xtests/http2-server.py6
-rw-r--r--tests/http2-test.c23
3 files changed, 34 insertions, 1 deletions
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index e5d08106..2dd1e356 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -477,8 +477,12 @@ io_read_ready (GObject *stream,
return G_SOURCE_CONTINUE;
}
- if (error)
+ if (error) {
set_io_error (io, error);
+ g_list_foreach (io->pending_io_messages,
+ (GFunc)soup_http2_message_data_check_status,
+ NULL);
+ }
io->is_shutdown = TRUE;
diff --git a/tests/http2-server.py b/tests/http2-server.py
index 977aff15..adccc2ea 100755
--- a/tests/http2-server.py
+++ b/tests/http2-server.py
@@ -44,6 +44,12 @@ async def slow():
await asyncio.sleep(1)
return 'Hello world'
+@app.route('/timeout')
+async def timeout():
+ set_timeout()
+ await asyncio.sleep(4)
+ return 'Hello world'
+
@app.route('/no-content')
async def no_content():
set_timeout()
diff --git a/tests/http2-test.c b/tests/http2-test.c
index c566505a..8ac00173 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -994,6 +994,25 @@ do_sniffer_sync_test (Test *test, gconstpointer data)
do_one_sniffer_test (test->session, "https://127.0.0.1:5000/no-content", 0, FALSE, NULL);
}
+static void
+do_timeout_test (Test *test, gconstpointer data)
+{
+ SoupMessage *msg;
+ GBytes *response;
+ GError *error = NULL;
+
+ soup_session_set_timeout (test->session, 2);
+
+ msg = soup_message_new (SOUP_METHOD_GET, "https://127.0.0.1:5000/timeout");
+ response = soup_test_session_async_send (test->session, msg, NULL, &error);
+ g_assert_null (response);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT);
+ g_object_unref (msg);
+
+ while (g_main_context_pending (NULL))
+ g_main_context_iteration (NULL, FALSE);
+}
+
int
main (int argc, char **argv)
{
@@ -1102,6 +1121,10 @@ main (int argc, char **argv)
setup_session,
do_sniffer_sync_test,
teardown_session);
+ g_test_add ("/http2/timeout", Test, NULL,
+ setup_session,
+ do_timeout_test,
+ teardown_session);
ret = g_test_run ();