[libsoup/wip/http2] WIP



commit a273f136c2a5d679068ba975cf763b4c901bb370
Author: Patrick Griffis <pgriffis igalia com>
Date:   Sat May 8 19:40:21 2021 -0500

    WIP

 libsoup/http2/soup-client-message-io-http2.c | 27 ++++++++++++++++-----------
 libsoup/soup-connection.c                    |  1 +
 2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 1baaa3e8..91f6180f 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -256,8 +256,6 @@ memory_stream_want_read_callback (SoupMemoryInputStream *stream, GCancellable *c
         SoupHTTP2MessageData *data = (SoupHTTP2MessageData*)user_data;
         GError *error = NULL;
 
-        g_debug ("memory_stream_want_read_callback write=%d read=%d", nghttp2_session_want_write 
(data->io->session), nghttp2_session_want_read (data->io->session));
-
         io_read_or_write (data->io, blocking, cancellable, &error);
 
         return error;
@@ -333,7 +331,7 @@ on_frame_recv_callback (nghttp2_session *session, const nghttp2_frame *frame, gp
         }
 
         if (!data) {
-                if (frame->hd.stream_id != 0 && frame->hd.flags != NGHTTP2_FLAG_END_STREAM)
+                if (frame->hd.stream_id != 0 && !(frame->hd.flags & NGHTTP2_FLAG_END_STREAM))
                         g_warn_if_reached ();
                 return 0;
         }
@@ -343,7 +341,7 @@ on_frame_recv_callback (nghttp2_session *session, const nghttp2_frame *frame, gp
                 if (data->metrics)
                         data->metrics->response_header_bytes_received += frame->hd.length + 
FRAME_HEADER_SIZE;
 
-                if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE && frame->hd.flags & 
NGHTTP2_FLAG_END_HEADERS) {
+                if (frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) {
                         h2_debug (io, data, "[HEADERS] status %u", soup_message_get_status (data->msg));
                         if (SOUP_STATUS_IS_INFORMATIONAL (soup_message_get_status (data->msg))) {
                                 soup_message_got_informational (data->msg);
@@ -372,12 +370,8 @@ on_frame_recv_callback (nghttp2_session *session, const nghttp2_frame *frame, gp
         };
 
         if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
-                h2_debug (io, data, "Stream done");
-                data->state = STATE_READ_DONE;
-                if (frame->hd.type == NGHTTP2_DATA) {
-                        soup_memory_input_stream_complete (SOUP_MEMORY_INPUT_STREAM 
(data->memory_data_istream));
-                        soup_message_got_body (data->msg);
-                }
+                h2_debug (io, data, "END_STREAM");
+
 
                 // soup_message_io_http2_finished (data->msg);
                 // nghttp2_submit_rst_stream (session, NGHTTP2_FLAG_NONE, frame->hd.stream_id, 
NGHTTP2_STREAM_CLOSED);
@@ -518,7 +512,18 @@ on_frame_not_send_callback (nghttp2_session *session, const nghttp2_frame *frame
 static int
 on_stream_close_callback (nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *user_data)
 {
-        g_debug ("on_stream_close %d", stream_id);
+        SoupHTTP2MessageData *data = nghttp2_session_get_stream_user_data (session, stream_id);
+
+        h2_debug (user_data, data, "[CLOSE]");
+
+        if (data->state < STATE_READ_DONE) {
+                data->state = STATE_READ_DONE;
+                if (data->memory_data_istream) {
+                        soup_memory_input_stream_complete (SOUP_MEMORY_INPUT_STREAM 
(data->memory_data_istream));
+                        soup_message_got_body (data->msg);
+                }
+        }
+
         return 0;
 }
 
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index b13738dc..72c512c7 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -321,6 +321,7 @@ soup_connection_event (SoupConnection      *conn,
 static gboolean
 idle_timeout (gpointer conn)
 {
+        g_message ("IDLE TIMEOUT!");
        soup_connection_disconnect (conn);
        return FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]