summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2022-05-06 09:59:39 +0200
committerCarlos Garcia Campos <cgarcia@igalia.com>2022-06-30 10:16:58 +0200
commit32ff82fc79ce5e1a57dd4e36e34403a2e5cf7a88 (patch)
tree387f509878d1c197e5af02e2edaa2f30165ba221
parentea600bd83925f099ad7a8f2615f75ec44d261c2c (diff)
downloadlibsoup-32ff82fc79ce5e1a57dd4e36e34403a2e5cf7a88.tar.gz
http2: read the request body stream synchronously for sync requests
Fixes #276
-rw-r--r--libsoup/http2/soup-client-message-io-http2.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 6e9e48b3..3164fa06 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -1048,6 +1048,31 @@ on_data_source_read_callback (nghttp2_session *session,
SoupHTTP2MessageData *data = nghttp2_session_get_stream_user_data (session, stream_id);
data->io->in_callback++;
+ if (!data->item->async) {
+ gssize read;
+ GError *error = NULL;
+
+ read = g_input_stream_read (source->ptr, buf, length, data->item->cancellable, &error);
+ if (read) {
+ h2_debug (data->io, data, "[SEND_BODY] Read %zd", read);
+ log_request_data (data, buf, read);
+ }
+
+ if (read < 0) {
+ set_error_for_data (data, g_steal_pointer (&error));
+ data->io->in_callback--;
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
+ }
+
+ if (read == 0) {
+ h2_debug (data->io, data, "[SEND_BODY] EOF");
+ *data_flags |= NGHTTP2_DATA_FLAG_EOF;
+ }
+
+ data->io->in_callback--;
+ return read;
+ }
+
/* We support pollable streams in the best case because they
* should perform better with one fewer copy of each buffer and no threading. */
if (G_IS_POLLABLE_INPUT_STREAM (source->ptr) && g_pollable_input_stream_can_poll (G_POLLABLE_INPUT_STREAM (source->ptr))) {