[libsoup/wip/http2] fixup! Add initial HTTP2 backend
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/http2] fixup! Add initial HTTP2 backend
- Date: Wed, 12 May 2021 18:30:58 +0000 (UTC)
commit 4bad2bce10a94eb033ae5d36b914a759d6c4005b
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed May 12 12:35:06 2021 -0500
fixup! Add initial HTTP2 backend
libsoup/http2/soup-client-message-io-http2.c | 12 +-
libsoup/http2/soup-memory-input-stream.c | 215 ++++++++++-----------------
2 files changed, 86 insertions(+), 141 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 613f5dc0..82b18801 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -246,10 +246,10 @@ on_header_callback (nghttp2_session *session,
}
static GError *
-memory_stream_want_read_callback (SoupMemoryInputStream *stream,
- GCancellable *cancellable,
- gboolean blocking,
- gpointer user_data)
+memory_stream_need_more_data_callback (SoupMemoryInputStream *stream,
+ GCancellable *cancellable,
+ gboolean blocking,
+ gpointer user_data)
{
SoupHTTP2MessageData *data = (SoupHTTP2MessageData*)user_data;
GError *error = NULL;
@@ -284,8 +284,8 @@ on_begin_frame_callback (nghttp2_session *session,
data->state = STATE_READ_DATA;
if (!data->memory_data_istream) {
data->memory_data_istream = soup_memory_input_stream_new (G_POLLABLE_INPUT_STREAM
(data->io->istream));
- g_signal_connect (data->memory_data_istream, "want-read",
- G_CALLBACK (memory_stream_want_read_callback), data);
+ g_signal_connect (data->memory_data_istream, "need-more-data",
+ G_CALLBACK (memory_stream_need_more_data_callback), data);
}
if (!data->decoded_data_istream)
data->decoded_data_istream = soup_message_setup_body_istream
(data->memory_data_istream, data->msg,
diff --git a/libsoup/http2/soup-memory-input-stream.c b/libsoup/http2/soup-memory-input-stream.c
index 88add784..ac9eee52 100644
--- a/libsoup/http2/soup-memory-input-stream.c
+++ b/libsoup/http2/soup-memory-input-stream.c
@@ -27,8 +27,6 @@
/**
* SECTION:SoupMemoryInputStream
* @short_description: Streaming input operations on memory chunks
- * @include: gio/gio.h
- * @see_also: #SoupMemoryOutputStream
*
* #SoupMemoryInputStream is a class for using arbitrary
* memory chunks as input for GIO streaming input operations.
@@ -52,61 +50,8 @@ typedef struct {
gboolean completed;
} SoupMemoryInputStreamPrivate;
-static gssize soup_memory_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gssize soup_memory_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean soup_memory_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void soup_memory_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer datae);
-static gssize soup_memory_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void soup_memory_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean soup_memory_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
static void soup_memory_input_stream_seekable_iface_init (GSeekableIface *iface);
-static goffset soup_memory_input_stream_tell (GSeekable *seekable);
-static gboolean soup_memory_input_stream_can_seek (GSeekable *seekable);
-static gboolean soup_memory_input_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean soup_memory_input_stream_can_truncate (GSeekable *seekable);
-static gboolean soup_memory_input_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
static void soup_memory_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
-static gboolean soup_memory_input_stream_is_readable (GPollableInputStream *stream);
-static GSource *soup_memory_input_stream_create_source (GPollableInputStream *stream,
- GCancellable *cancellable);
-static gssize soup_memory_input_stream_read_nonblocking (GPollableInputStream *stream,
- void *buffer,
- gsize count,
- GError **error);
-
-static void soup_memory_input_stream_dispose (GObject *object);
-static void soup_memory_input_stream_finalize (GObject *object);
G_DEFINE_TYPE_WITH_CODE (SoupMemoryInputStream, soup_memory_input_stream, G_TYPE_INPUT_STREAM,
G_ADD_PRIVATE (SoupMemoryInputStream)
@@ -116,89 +61,12 @@ G_DEFINE_TYPE_WITH_CODE (SoupMemoryInputStream, soup_memory_input_stream, G_TYPE
soup_memory_input_stream_pollable_iface_init);)
enum {
- WANT_READ,
+ NEED_MORE_DATA,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0 };
-static void
-soup_memory_input_stream_class_init (SoupMemoryInputStreamClass *klass)
-{
- GObjectClass *object_class;
- GInputStreamClass *istream_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = soup_memory_input_stream_finalize;
- object_class->dispose = soup_memory_input_stream_dispose;
-
- istream_class = G_INPUT_STREAM_CLASS (klass);
- istream_class->read_fn = soup_memory_input_stream_read;
- istream_class->skip = soup_memory_input_stream_skip;
- istream_class->close_fn = soup_memory_input_stream_close;
-
- istream_class->skip_async = soup_memory_input_stream_skip_async;
- istream_class->skip_finish = soup_memory_input_stream_skip_finish;
- istream_class->close_async = soup_memory_input_stream_close_async;
- istream_class->close_finish = soup_memory_input_stream_close_finish;
-
- signals[WANT_READ] =
- g_signal_new ("want-read",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- NULL,
- G_TYPE_ERROR,
- 2, G_TYPE_CANCELLABLE, G_TYPE_BOOLEAN);
-}
-
-static void
-soup_memory_input_stream_dispose (GObject *object)
-{
- SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
-
- priv->completed = TRUE;
-
- G_OBJECT_CLASS (soup_memory_input_stream_parent_class)->dispose (object);
-}
-
-static void
-soup_memory_input_stream_finalize (GObject *object)
-{
- SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
-
- g_slist_free_full (priv->chunks, (GDestroyNotify)g_bytes_unref);
- g_clear_object (&priv->parent_stream);
-
- G_OBJECT_CLASS (soup_memory_input_stream_parent_class)->finalize (object);
-}
-
-static void
-soup_memory_input_stream_seekable_iface_init (GSeekableIface *iface)
-{
- iface->tell = soup_memory_input_stream_tell;
- iface->can_seek = soup_memory_input_stream_can_seek;
- iface->seek = soup_memory_input_stream_seek;
- iface->can_truncate = soup_memory_input_stream_can_truncate;
- iface->truncate_fn = soup_memory_input_stream_truncate;
-}
-
-static void
-soup_memory_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
-{
- iface->is_readable = soup_memory_input_stream_is_readable;
- iface->create_source = soup_memory_input_stream_create_source;
- iface->read_nonblocking = soup_memory_input_stream_read_nonblocking;
-}
-
-static void
-soup_memory_input_stream_init (SoupMemoryInputStream *stream)
-{
-}
-
/**
* soup_memory_input_stream_new:
*
@@ -306,7 +174,7 @@ soup_memory_input_stream_read_real (GInputStream *stream,
// So emit a signal saying we need more data.
if (count == 0 && blocking && !priv->completed) {
GError *read_error = NULL;
- g_signal_emit (memory_stream, signals[WANT_READ], 0,
+ g_signal_emit (memory_stream, signals[NEED_MORE_DATA], 0,
cancellable,
TRUE,
&read_error);
@@ -351,7 +219,7 @@ soup_memory_input_stream_read_nonblocking (GPollableInputStream *stream,
// Try requesting more reads from the io backend
GError *inner_error = NULL;
- g_signal_emit (memory_stream, signals[WANT_READ], 0,
+ g_signal_emit (memory_stream, signals[NEED_MORE_DATA], 0,
NULL, FALSE, &inner_error);
// TODO: Do we care?
@@ -609,3 +477,80 @@ soup_memory_input_stream_create_source (GPollableInputStream *stream,
return source;
}
+
+static void
+soup_memory_input_stream_dispose (GObject *object)
+{
+ SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
+ SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
+
+ priv->completed = TRUE;
+
+ G_OBJECT_CLASS (soup_memory_input_stream_parent_class)->dispose (object);
+}
+
+static void
+soup_memory_input_stream_finalize (GObject *object)
+{
+ SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
+ SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
+
+ g_slist_free_full (priv->chunks, (GDestroyNotify)g_bytes_unref);
+ g_clear_object (&priv->parent_stream);
+
+ G_OBJECT_CLASS (soup_memory_input_stream_parent_class)->finalize (object);
+}
+
+static void
+soup_memory_input_stream_seekable_iface_init (GSeekableIface *iface)
+{
+ iface->tell = soup_memory_input_stream_tell;
+ iface->can_seek = soup_memory_input_stream_can_seek;
+ iface->seek = soup_memory_input_stream_seek;
+ iface->can_truncate = soup_memory_input_stream_can_truncate;
+ iface->truncate_fn = soup_memory_input_stream_truncate;
+}
+
+static void
+soup_memory_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
+{
+ iface->is_readable = soup_memory_input_stream_is_readable;
+ iface->create_source = soup_memory_input_stream_create_source;
+ iface->read_nonblocking = soup_memory_input_stream_read_nonblocking;
+}
+
+static void
+soup_memory_input_stream_init (SoupMemoryInputStream *stream)
+{
+}
+
+static void
+soup_memory_input_stream_class_init (SoupMemoryInputStreamClass *klass)
+{
+ GObjectClass *object_class;
+ GInputStreamClass *istream_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = soup_memory_input_stream_finalize;
+ object_class->dispose = soup_memory_input_stream_dispose;
+
+ istream_class = G_INPUT_STREAM_CLASS (klass);
+ istream_class->read_fn = soup_memory_input_stream_read;
+ istream_class->skip = soup_memory_input_stream_skip;
+ istream_class->close_fn = soup_memory_input_stream_close;
+
+ istream_class->skip_async = soup_memory_input_stream_skip_async;
+ istream_class->skip_finish = soup_memory_input_stream_skip_finish;
+ istream_class->close_async = soup_memory_input_stream_close_async;
+ istream_class->close_finish = soup_memory_input_stream_close_finish;
+
+ signals[NEED_MORE_DATA] =
+ g_signal_new ("need-more-data",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_ERROR,
+ 2, G_TYPE_CANCELLABLE, G_TYPE_BOOLEAN);
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]