[libsoup/carlosgc/http2-io-errors: 3/8] http2: handle connection terminated unexpectedly error when reading
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/carlosgc/http2-io-errors: 3/8] http2: handle connection terminated unexpectedly error when reading
- Date: Wed, 31 Aug 2022 09:09:51 +0000 (UTC)
commit fe1e6244678b61a638fb092cbcfa97230cb9bab3
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Aug 29 09:21:44 2022 +0200
http2: handle connection terminated unexpectedly error when reading
libsoup/http2/soup-client-message-io-http2.c | 9 ++++++++-
libsoup/server/http2/soup-server-message-io-http2.c | 16 +++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index a1ad1880..0ccdf878 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -359,10 +359,17 @@ io_read (SoupClientMessageIOHTTP2 *io,
blocking, cancellable, error)) < 0)
return FALSE;
+ if (read == 0) {
+ g_set_error_literal (error, G_IO_ERROR,
+ G_IO_ERROR_PARTIAL_INPUT,
+ _("Connection terminated unexpectedly"));
+ return FALSE;
+ }
+
g_warn_if_fail (io->in_callback == 0);
ret = nghttp2_session_mem_recv (io->session, buffer, read);
NGCHECK (ret);
- return ret != 0;
+ return ret > 0;
}
static gboolean
diff --git a/libsoup/server/http2/soup-server-message-io-http2.c
b/libsoup/server/http2/soup-server-message-io-http2.c
index 2e32b0aa..81a5dd3c 100644
--- a/libsoup/server/http2/soup-server-message-io-http2.c
+++ b/libsoup/server/http2/soup-server-message-io-http2.c
@@ -406,11 +406,25 @@ io_read (SoupServerMessageIOHTTP2 *io,
{
guint8 buffer[8192];
gssize read;
+ int ret;
if ((read = g_pollable_stream_read (io->istream, buffer, sizeof (buffer), FALSE, NULL, error)) < 0)
return FALSE;
- return nghttp2_session_mem_recv (io->session, buffer, read) != 0;
+ if (read == 0) {
+ g_set_error_literal (error, G_IO_ERROR,
+ G_IO_ERROR_PARTIAL_INPUT,
+ _("Connection terminated unexpectedly"));
+ return FALSE;
+ }
+
+ ret = nghttp2_session_mem_recv (io->session, buffer, read);
+ if (ret < 0) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "HTTP/2 IO error: %s", nghttp2_strerror
(ret));
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]