[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 19:07:06 +0000 (UTC)
commit 1657f217238ff84a8978eaa7ad595f379b8ecbd0
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed May 12 14:06:59 2021 -0500
fixup! Add initial HTTP2 backend
docs/reference/meson.build | 2 +-
...put-stream.c => soup-body-input-stream-http2.c} | 270 ++++++++++-----------
libsoup/http2/soup-body-input-stream-http2.h | 17 ++
libsoup/http2/soup-client-message-io-http2.c | 34 +--
libsoup/http2/soup-memory-input-stream.h | 17 --
libsoup/meson.build | 2 +-
...mory-stream-test.c => http2-body-stream-test.c} | 20 +-
tests/http2-test.c | 10 +-
tests/meson.build | 2 +-
9 files changed, 187 insertions(+), 187 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 7872b2b0..c11db34a 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -42,7 +42,7 @@ ignore_headers = [
'soup-message-io-completion.h',
'soup-client-message-io-http1.h',
'soup-client-message-io-http2.h',
- 'soup-memory-input-stream.h',
+ 'soup-body-input-stream-http2.h',
]
mkdb_args = [
diff --git a/libsoup/http2/soup-memory-input-stream.c b/libsoup/http2/soup-body-input-stream-http2.c
similarity index 53%
rename from libsoup/http2/soup-memory-input-stream.c
rename to libsoup/http2/soup-body-input-stream-http2.c
index adae2249..42e592dd 100644
--- a/libsoup/http2/soup-memory-input-stream.c
+++ b/libsoup/http2/soup-body-input-stream-http2.c
@@ -21,23 +21,23 @@
#include "config.h"
-#include "soup-memory-input-stream.h"
+#include "soup-body-input-stream-http2.h"
#include <glib/gi18n-lib.h>
/**
- * SECTION:SoupMemoryInputStream
+ * SECTION:SoupBodyInputStreamHttp2
* @short_description: Streaming input operations on memory chunks
*
- * #SoupMemoryInputStream is a class for using arbitrary
+ * #SoupBodyInputStreamHttp2 is a class for using arbitrary
* memory chunks as input for GIO streaming input operations.
*
* It differs from #GMemoryInputStream in that it frees older chunks
* after they have been read, returns #G_IO_ERROR_WOULDBLOCK at the end
- * of data until soup_memory_input_stream_complete() is called, and implements
+ * of data until soup_body_input_stream_http2_complete() is called, and implements
* g_pollable_input_stream_is_readable().
*/
-struct _SoupMemoryInputStream {
+struct _SoupBodyInputStreamHttp2 {
GInputStream parent_instance;
};
@@ -48,17 +48,17 @@ typedef struct {
gsize len;
gsize pos;
gboolean completed;
-} SoupMemoryInputStreamPrivate;
+} SoupBodyInputStreamHttp2Private;
-static void soup_memory_input_stream_seekable_iface_init (GSeekableIface *iface);
-static void soup_memory_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
+static void soup_body_input_stream_http2_seekable_iface_init (GSeekableIface *iface);
+static void soup_body_input_stream_http2_pollable_iface_init (GPollableInputStreamInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (SoupMemoryInputStream, soup_memory_input_stream, G_TYPE_INPUT_STREAM,
- G_ADD_PRIVATE (SoupMemoryInputStream)
+G_DEFINE_TYPE_WITH_CODE (SoupBodyInputStreamHttp2, soup_body_input_stream_http2, G_TYPE_INPUT_STREAM,
+ G_ADD_PRIVATE (SoupBodyInputStreamHttp2)
G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- soup_memory_input_stream_seekable_iface_init);
+ soup_body_input_stream_http2_seekable_iface_init);
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
- soup_memory_input_stream_pollable_iface_init);)
+ soup_body_input_stream_http2_pollable_iface_init);)
enum {
NEED_MORE_DATA,
@@ -68,20 +68,20 @@ enum {
static guint signals [LAST_SIGNAL] = { 0 };
/**
- * soup_memory_input_stream_new:
+ * soup_body_input_stream_http2_new:
*
- * Creates a new empty #SoupMemoryInputStream.
+ * Creates a new empty #SoupBodyInputStreamHttp2.
*
* Returns: a new #GInputStream
*/
GInputStream *
-soup_memory_input_stream_new (GPollableInputStream *parent_stream)
+soup_body_input_stream_http2_new (GPollableInputStream *parent_stream)
{
GInputStream *stream;
- SoupMemoryInputStreamPrivate *priv;
+ SoupBodyInputStreamHttp2Private *priv;
- stream = g_object_new (SOUP_TYPE_MEMORY_INPUT_STREAM, NULL);
- priv = soup_memory_input_stream_get_instance_private (SOUP_MEMORY_INPUT_STREAM (stream));
+ stream = g_object_new (SOUP_TYPE_BODY_INPUT_STREAM_HTTP2, NULL);
+ priv = soup_body_input_stream_http2_get_instance_private (SOUP_BODY_INPUT_STREAM_HTTP2 (stream));
if (parent_stream)
priv->parent_stream = g_object_ref (parent_stream);
@@ -89,39 +89,39 @@ soup_memory_input_stream_new (GPollableInputStream *parent_stream)
}
void
-soup_memory_input_stream_add_data (SoupMemoryInputStream *stream,
- const guint8 *data,
- gsize size)
+soup_body_input_stream_http2_add_data (SoupBodyInputStreamHttp2 *stream,
+ const guint8 *data,
+ gsize size)
{
- SoupMemoryInputStreamPrivate *priv;
+ SoupBodyInputStreamHttp2Private *priv;
- g_return_if_fail (SOUP_IS_MEMORY_INPUT_STREAM (stream));
+ g_return_if_fail (SOUP_IS_BODY_INPUT_STREAM_HTTP2 (stream));
g_return_if_fail (data != NULL);
- priv = soup_memory_input_stream_get_instance_private (stream);
+ priv = soup_body_input_stream_http2_get_instance_private (stream);
priv->chunks = g_slist_append (priv->chunks, g_bytes_new (data, size));
priv->len += size;
}
static gssize
-soup_memory_input_stream_read_real (GInputStream *stream,
- gboolean blocking,
- void *buffer,
- gsize read_count,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_read_real (GInputStream *stream,
+ gboolean blocking,
+ void *buffer,
+ gsize read_count,
+ GCancellable *cancellable,
+ GError **error)
{
- SoupMemoryInputStream *memory_stream;
- SoupMemoryInputStreamPrivate *priv;
+ SoupBodyInputStreamHttp2 *memory_stream;
+ SoupBodyInputStreamHttp2Private *priv;
GSList *l;
GBytes *chunk;
gsize len;
gsize offset, start, rest, size;
gsize count;
- memory_stream = SOUP_MEMORY_INPUT_STREAM (stream);
- priv = soup_memory_input_stream_get_instance_private (memory_stream);
+ memory_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
+ priv = soup_body_input_stream_http2_get_instance_private (memory_stream);
/* We have a list of chunked bytes that we continually read from.
* Once a chunk is fully read it is removed from our list and we
@@ -185,7 +185,7 @@ soup_memory_input_stream_read_real (GInputStream *stream,
return -1;
}
- return soup_memory_input_stream_read_real (
+ return soup_body_input_stream_http2_read_real (
stream, blocking, buffer, read_count, cancellable, error
);
}
@@ -194,26 +194,26 @@ soup_memory_input_stream_read_real (GInputStream *stream,
}
static gssize
-soup_memory_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_read (GInputStream *stream,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error)
{
- return soup_memory_input_stream_read_real (stream, TRUE, buffer, count, cancellable, error);
+ return soup_body_input_stream_http2_read_real (stream, TRUE, buffer, count, cancellable, error);
}
static gssize
-soup_memory_input_stream_read_nonblocking (GPollableInputStream *stream,
- void *buffer,
- gsize count,
- GError **error)
+soup_body_input_stream_http2_read_nonblocking (GPollableInputStream *stream,
+ void *buffer,
+ gsize count,
+ GError **error)
{
- SoupMemoryInputStream *memory_stream = SOUP_MEMORY_INPUT_STREAM (stream);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (memory_stream);
+ SoupBodyInputStreamHttp2 *memory_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_get_instance_private
(memory_stream);
GError *inner_error = NULL;
- gsize read = soup_memory_input_stream_read_real (G_INPUT_STREAM (stream), FALSE, buffer, count,
NULL, &inner_error);
+ gsize read = soup_body_input_stream_http2_read_real (G_INPUT_STREAM (stream), FALSE, buffer, count,
NULL, &inner_error);
if (read == 0 && !priv->completed && !inner_error) {
/* Try requesting more reads from the io backend */
@@ -227,7 +227,7 @@ soup_memory_input_stream_read_nonblocking (GPollableInputStream *stream,
}
/* Immediately return any data read */
- read = soup_memory_input_stream_read_real (G_INPUT_STREAM (stream), FALSE, buffer, count,
NULL, &inner_error);
+ read = soup_body_input_stream_http2_read_real (G_INPUT_STREAM (stream), FALSE, buffer,
count, NULL, &inner_error);
if (read == 0) {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, "Operation would
block");
return -1;
@@ -241,23 +241,23 @@ soup_memory_input_stream_read_nonblocking (GPollableInputStream *stream,
}
void
-soup_memory_input_stream_complete (SoupMemoryInputStream *stream)
+soup_body_input_stream_http2_complete (SoupBodyInputStreamHttp2 *stream)
{
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_get_instance_private (stream);
priv->completed = TRUE;
}
static gssize
-soup_memory_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_skip (GInputStream *stream,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error)
{
- SoupMemoryInputStream *memory_stream;
- SoupMemoryInputStreamPrivate *priv;
+ SoupBodyInputStreamHttp2 *memory_stream;
+ SoupBodyInputStreamHttp2Private *priv;
- memory_stream = SOUP_MEMORY_INPUT_STREAM (stream);
- priv = soup_memory_input_stream_get_instance_private (memory_stream);
+ memory_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
+ priv = soup_body_input_stream_http2_get_instance_private (memory_stream);
count = MIN (count, priv->len - priv->pos);
priv->pos += count;
@@ -281,15 +281,15 @@ soup_memory_input_stream_skip (GInputStream *stream,
}
static gboolean
-soup_memory_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
{
return TRUE;
}
static void
-soup_memory_input_stream_skip_async (GInputStream *stream,
+soup_body_input_stream_http2_skip_async (GInputStream *stream,
gsize count,
int io_priority,
GCancellable *cancellable,
@@ -302,7 +302,7 @@ soup_memory_input_stream_skip_async (GInputStream *stream,
nskipped = G_INPUT_STREAM_GET_CLASS (stream)->skip (stream, count, cancellable, &error);
task = g_task_new (stream, cancellable, callback, user_data);
- g_task_set_source_tag (task, soup_memory_input_stream_skip_async);
+ g_task_set_source_tag (task, soup_body_input_stream_http2_skip_async);
if (error)
g_task_return_error (task, error);
@@ -312,9 +312,9 @@ soup_memory_input_stream_skip_async (GInputStream *stream,
}
static gssize
-soup_memory_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
+soup_body_input_stream_http2_skip_finish (GInputStream *stream,
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, stream), -1);
@@ -322,83 +322,83 @@ soup_memory_input_stream_skip_finish (GInputStream *stream,
}
static void
-soup_memory_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+soup_body_input_stream_http2_close_async (GInputStream *stream,
+ int io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
task = g_task_new (stream, cancellable, callback, user_data);
- g_task_set_source_tag (task, soup_memory_input_stream_close_async);
+ g_task_set_source_tag (task, soup_body_input_stream_http2_close_async);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static gboolean
-soup_memory_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
+soup_body_input_stream_http2_close_finish (GInputStream *stream,
+ GAsyncResult *result,
+ GError **error)
{
return TRUE;
}
static goffset
-soup_memory_input_stream_tell (GSeekable *seekable)
+soup_body_input_stream_http2_tell (GSeekable *seekable)
{
- SoupMemoryInputStream *memory_stream;
- SoupMemoryInputStreamPrivate *priv;
+ SoupBodyInputStreamHttp2 *memory_stream;
+ SoupBodyInputStreamHttp2Private *priv;
- memory_stream = SOUP_MEMORY_INPUT_STREAM (seekable);
- priv = soup_memory_input_stream_get_instance_private (memory_stream);
+ memory_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (seekable);
+ priv = soup_body_input_stream_http2_get_instance_private (memory_stream);
return priv->pos;
}
-static gboolean soup_memory_input_stream_can_seek (GSeekable *seekable)
+static gboolean soup_body_input_stream_http2_can_seek (GSeekable *seekable)
{
return FALSE;
}
static gboolean
-soup_memory_input_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_seek (GSeekable *seekable,
+ goffset offset,
+ GSeekType type,
+ GCancellable *cancellable,
+ GError **error)
{
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
- _ ("Cannot seek SoupMemoryInputStream"));
+ _ ("Cannot seek SoupBodyInputStreamHttp2"));
return FALSE;
}
static gboolean
-soup_memory_input_stream_can_truncate (GSeekable *seekable)
+soup_body_input_stream_http2_can_truncate (GSeekable *seekable)
{
return FALSE;
}
static gboolean
-soup_memory_input_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
+soup_body_input_stream_http2_truncate (GSeekable *seekable,
+ goffset offset,
+ GCancellable *cancellable,
+ GError **error)
{
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
- _ ("Cannot truncate SoupMemoryInputStream"));
+ _ ("Cannot truncate SoupBodyInputStreamHttp2"));
return FALSE;
}
static gboolean
-soup_memory_input_stream_is_readable (GPollableInputStream *stream)
+soup_body_input_stream_http2_is_readable (GPollableInputStream *stream)
{
- SoupMemoryInputStream *memory_stream = SOUP_MEMORY_INPUT_STREAM (stream);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (memory_stream);
+ SoupBodyInputStreamHttp2 *memory_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_get_instance_private
(memory_stream);
return priv->pos < priv->len || priv->completed;
}
@@ -407,7 +407,7 @@ soup_memory_input_stream_is_readable (GPollableInputStream *stream)
typedef struct {
GSource source;
- SoupMemoryInputStream *stream;
+ SoupBodyInputStreamHttp2 *stream;
} SoupMemoryStreamSource;
static gboolean
@@ -415,7 +415,7 @@ memory_stream_source_prepare (GSource *source,
gint *timeout)
{
SoupMemoryStreamSource *stream_source = (SoupMemoryStreamSource *)source;
- return soup_memory_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (stream_source->stream));
+ return soup_body_input_stream_http2_is_readable (G_POLLABLE_INPUT_STREAM (stream_source->stream));
}
static gboolean
@@ -433,8 +433,8 @@ memory_stream_source_dispatch (GSource *source,
}
static gboolean
-memory_stream_source_closure_callback (GObject *pollable_stream,
- gpointer data)
+memory_stream_source_closure_callback (GObject *pollable_stream,
+ gpointer data)
{
GClosure *closure = data;
GValue param = G_VALUE_INIT;
@@ -475,16 +475,16 @@ static GSourceFuncs source_funcs =
};
static GSource *
-soup_memory_input_stream_create_source (GPollableInputStream *stream,
- GCancellable *cancellable)
+soup_body_input_stream_http2_create_source (GPollableInputStream *stream,
+ GCancellable *cancellable)
{
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private
(SOUP_MEMORY_INPUT_STREAM (stream));
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_get_instance_private
(SOUP_BODY_INPUT_STREAM_HTTP2 (stream));
GSource *source = g_source_new (&source_funcs, sizeof (SoupMemoryStreamSource));
g_source_set_name (source, "SoupMemoryStreamSource");
SoupMemoryStreamSource *stream_source = (SoupMemoryStreamSource *)source;
- stream_source->stream = g_object_ref (SOUP_MEMORY_INPUT_STREAM (stream));
+ stream_source->stream = g_object_ref (SOUP_BODY_INPUT_STREAM_HTTP2 (stream));
GSource *child_source;
if (priv->parent_stream)
@@ -500,70 +500,70 @@ soup_memory_input_stream_create_source (GPollableInputStream *stream,
}
static void
-soup_memory_input_stream_dispose (GObject *object)
+soup_body_input_stream_http2_dispose (GObject *object)
{
- SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
+ SoupBodyInputStreamHttp2 *stream = SOUP_BODY_INPUT_STREAM_HTTP2 (object);
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_get_instance_private (stream);
priv->completed = TRUE;
- G_OBJECT_CLASS (soup_memory_input_stream_parent_class)->dispose (object);
+ G_OBJECT_CLASS (soup_body_input_stream_http2_parent_class)->dispose (object);
}
static void
-soup_memory_input_stream_finalize (GObject *object)
+soup_body_input_stream_http2_finalize (GObject *object)
{
- SoupMemoryInputStream *stream = SOUP_MEMORY_INPUT_STREAM (object);
- SoupMemoryInputStreamPrivate *priv = soup_memory_input_stream_get_instance_private (stream);
+ SoupBodyInputStreamHttp2 *stream = SOUP_BODY_INPUT_STREAM_HTTP2 (object);
+ SoupBodyInputStreamHttp2Private *priv = soup_body_input_stream_http2_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);
+ G_OBJECT_CLASS (soup_body_input_stream_http2_parent_class)->finalize (object);
}
static void
-soup_memory_input_stream_seekable_iface_init (GSeekableIface *iface)
+soup_body_input_stream_http2_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;
+ iface->tell = soup_body_input_stream_http2_tell;
+ iface->can_seek = soup_body_input_stream_http2_can_seek;
+ iface->seek = soup_body_input_stream_http2_seek;
+ iface->can_truncate = soup_body_input_stream_http2_can_truncate;
+ iface->truncate_fn = soup_body_input_stream_http2_truncate;
}
static void
-soup_memory_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
+soup_body_input_stream_http2_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;
+ iface->is_readable = soup_body_input_stream_http2_is_readable;
+ iface->create_source = soup_body_input_stream_http2_create_source;
+ iface->read_nonblocking = soup_body_input_stream_http2_read_nonblocking;
}
static void
-soup_memory_input_stream_init (SoupMemoryInputStream *stream)
+soup_body_input_stream_http2_init (SoupBodyInputStreamHttp2 *stream)
{
}
static void
-soup_memory_input_stream_class_init (SoupMemoryInputStreamClass *klass)
+soup_body_input_stream_http2_class_init (SoupBodyInputStreamHttp2Class *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;
+ object_class->finalize = soup_body_input_stream_http2_finalize;
+ object_class->dispose = soup_body_input_stream_http2_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;
+ istream_class->read_fn = soup_body_input_stream_http2_read;
+ istream_class->skip = soup_body_input_stream_http2_skip;
+ istream_class->close_fn = soup_body_input_stream_http2_close;
+
+ istream_class->skip_async = soup_body_input_stream_http2_skip_async;
+ istream_class->skip_finish = soup_body_input_stream_http2_skip_finish;
+ istream_class->close_async = soup_body_input_stream_http2_close_async;
+ istream_class->close_finish = soup_body_input_stream_http2_close_finish;
signals[NEED_MORE_DATA] =
g_signal_new ("need-more-data",
diff --git a/libsoup/http2/soup-body-input-stream-http2.h b/libsoup/http2/soup-body-input-stream-http2.h
new file mode 100644
index 00000000..9e25ed34
--- /dev/null
+++ b/libsoup/http2/soup-body-input-stream-http2.h
@@ -0,0 +1,17 @@
+
+#pragma once
+
+#include "soup-types.h"
+
+#define SOUP_TYPE_BODY_INPUT_STREAM_HTTP2 (soup_body_input_stream_http2_get_type ())
+G_DECLARE_FINAL_TYPE (SoupBodyInputStreamHttp2, soup_body_input_stream_http2, SOUP, BODY_INPUT_STREAM_HTTP2,
GInputStream)
+
+GInputStream * soup_body_input_stream_http2_new (GPollableInputStream *parent_stream);
+
+void soup_body_input_stream_http2_add_data (SoupBodyInputStreamHttp2 *stream,
+ const guint8 *data,
+ gsize size);
+
+void soup_body_input_stream_http2_complete (SoupBodyInputStreamHttp2 *stream);
+
+G_END_DECLS
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index f463a90c..9934fdf3 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -41,7 +41,7 @@
#include "soup-uri-utils-private.h"
#include "content-decoder/soup-content-decoder.h"
-#include "soup-memory-input-stream.h"
+#include "soup-body-input-stream-http2.h"
#include <nghttp2/nghttp2.h>
@@ -87,7 +87,7 @@ typedef struct {
SoupMessageMetrics *metrics;
GCancellable *cancellable;
GInputStream *decoded_data_istream;
- GInputStream *memory_data_istream;
+ GInputStream *body_istream;
/* Request body logger */
SoupLogger *logger;
@@ -246,10 +246,10 @@ on_header_callback (nghttp2_session *session,
}
static GError *
-memory_stream_need_more_data_callback (SoupMemoryInputStream *stream,
- GCancellable *cancellable,
- gboolean blocking,
- gpointer user_data)
+memory_stream_need_more_data_callback (SoupBodyInputStreamHttp2 *stream,
+ GCancellable *cancellable,
+ gboolean blocking,
+ gpointer user_data)
{
SoupHTTP2MessageData *data = (SoupHTTP2MessageData*)user_data;
GError *error = NULL;
@@ -282,13 +282,13 @@ on_begin_frame_callback (nghttp2_session *session,
/* We may have sniffed a previous DATA frame */
if (data->state < STATE_READ_DATA)
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, "need-more-data",
+ if (!data->body_istream) {
+ data->body_istream = soup_body_input_stream_http2_new (G_POLLABLE_INPUT_STREAM
(data->io->istream));
+ g_signal_connect (data->body_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,
+ data->decoded_data_istream = soup_message_setup_body_istream (data->body_istream,
data->msg,
data->item->session,
SOUP_STAGE_MESSAGE_BODY);
break;
}
@@ -352,7 +352,7 @@ on_frame_recv_callback (nghttp2_session *session,
if (SOUP_STATUS_IS_INFORMATIONAL (soup_message_get_status (data->msg))) {
soup_message_got_informational (data->msg);
soup_message_cleanup_response (data->msg);
- soup_memory_input_stream_complete (SOUP_MEMORY_INPUT_STREAM
(data->memory_data_istream));
+ soup_body_input_stream_http2_complete (SOUP_BODY_INPUT_STREAM_HTTP2
(data->body_istream));
data->state = STATE_READ_DONE;
break;
} else if (soup_message_get_status (data->msg) == SOUP_STATUS_NO_CONTENT) {
@@ -379,7 +379,7 @@ on_frame_recv_callback (nghttp2_session *session,
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_body_input_stream_http2_complete (SOUP_BODY_INPUT_STREAM_HTTP2
(data->body_istream));
soup_message_got_body (data->msg);
}
}
@@ -407,8 +407,8 @@ on_data_chunk_recv_callback (nghttp2_session *session,
return NGHTTP2_ERR_PAUSE;
SoupMessage *msg = msgdata->msg;
- g_assert (msgdata->memory_data_istream != NULL);
- soup_memory_input_stream_add_data (SOUP_MEMORY_INPUT_STREAM (msgdata->memory_data_istream), data,
len);
+ g_assert (msgdata->body_istream != NULL);
+ soup_body_input_stream_http2_add_data (SOUP_BODY_INPUT_STREAM_HTTP2 (msgdata->body_istream), data,
len);
if (msgdata->state < STATE_READ_DATA_SNIFFED) {
if (soup_message_get_content_sniffer (msg)) {
@@ -723,7 +723,7 @@ static void
soup_http2_message_data_free (SoupHTTP2MessageData *data)
{
g_clear_pointer (&data->item, soup_message_queue_item_unref);
- g_clear_object (&data->memory_data_istream);
+ g_clear_object (&data->body_istream);
g_clear_object (&data->decoded_data_istream);
if (data->io_source) {
@@ -999,9 +999,9 @@ soup_client_message_io_http2_skip_body (SoupClientMessageIO *iface,
g_debug ("soup_client_message_io_http2_skip_body");
- g_assert (data->memory_data_istream);
+ g_assert (data->body_istream);
- soup_memory_input_stream_complete (SOUP_MEMORY_INPUT_STREAM (data->memory_data_istream));
+ soup_body_input_stream_http2_complete (SOUP_BODY_INPUT_STREAM_HTTP2 (data->body_istream));
data->state = STATE_READ_DONE;
soup_message_got_body (data->msg);
}
diff --git a/libsoup/meson.build b/libsoup/meson.build
index 68de84cc..29911564 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -33,7 +33,7 @@ soup_sources = [
'hsts/soup-hsts-policy.c',
'http2/soup-client-message-io-http2.c',
- 'http2/soup-memory-input-stream.c',
+ 'http2/soup-body-input-stream-http2.c',
'server/soup-auth-domain.c',
'server/soup-auth-domain-basic.c',
diff --git a/tests/memory-stream-test.c b/tests/http2-body-stream-test.c
similarity index 78%
rename from tests/memory-stream-test.c
rename to tests/http2-body-stream-test.c
index de0e4053..d5fde7c1 100644
--- a/tests/memory-stream-test.c
+++ b/tests/http2-body-stream-test.c
@@ -18,7 +18,7 @@
*/
#include "test-utils.h"
-#include "soup-memory-input-stream.h"
+#include "soup-body-input-stream-http2.h"
static void
do_large_data_test (void)
@@ -26,8 +26,8 @@ do_large_data_test (void)
#define CHUNK_SIZE (gsize)1024 * 1024 * 512 // 512 MiB
#define TEST_SIZE CHUNK_SIZE * 20 // 10 GiB
- GInputStream *stream = soup_memory_input_stream_new (NULL);
- SoupMemoryInputStream *mem_stream = SOUP_MEMORY_INPUT_STREAM (stream);
+ GInputStream *stream = soup_body_input_stream_http2_new (NULL);
+ SoupBodyInputStreamHttp2 *mem_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
gsize data_needed = TEST_SIZE;
guint8 *memory_chunk = g_new (guint8, CHUNK_SIZE);
guint8 *trash_buffer = g_new (guint8, CHUNK_SIZE);
@@ -37,7 +37,7 @@ do_large_data_test (void)
while (data_needed > 0) {
/* Copy chunk */
- soup_memory_input_stream_add_data (mem_stream, memory_chunk, CHUNK_SIZE);
+ soup_body_input_stream_http2_add_data (mem_stream, memory_chunk, CHUNK_SIZE);
/* This should free the copy */
gssize read = g_input_stream_read (stream, trash_buffer, CHUNK_SIZE, NULL, NULL);
@@ -47,7 +47,7 @@ do_large_data_test (void)
data_needed = TEST_SIZE;
while (data_needed > 0) {
- soup_memory_input_stream_add_data (mem_stream, memory_chunk, CHUNK_SIZE);
+ soup_body_input_stream_http2_add_data (mem_stream, memory_chunk, CHUNK_SIZE);
/* Skipping also frees the copy */
gssize skipped = g_input_stream_skip (stream, CHUNK_SIZE, NULL, NULL);
@@ -63,14 +63,14 @@ do_large_data_test (void)
static void
do_multiple_chunk_test (void)
{
- GInputStream *stream = soup_memory_input_stream_new (NULL);
- SoupMemoryInputStream *mem_stream = SOUP_MEMORY_INPUT_STREAM (stream);
+ GInputStream *stream = soup_body_input_stream_http2_new (NULL);
+ SoupBodyInputStreamHttp2 *mem_stream = SOUP_BODY_INPUT_STREAM_HTTP2 (stream);
const char * const chunks[] = {
"1234", "5678", "9012", "hell", "owor", "ld..",
};
for (guint i = 0; i < G_N_ELEMENTS (chunks); ++i)
- soup_memory_input_stream_add_data (mem_stream, (guint8*)chunks[i], 4);
+ soup_body_input_stream_http2_add_data (mem_stream, (guint8*)chunks[i], 4);
/* Do partial reads of chunks to ensure it always comes out as expected */
for (guint i = 0; i < G_N_ELEMENTS (chunks); ++i) {
@@ -92,8 +92,8 @@ main (int argc, char **argv)
test_init (argc, argv, NULL);
- g_test_add_func ("/memory_stream/large_data", do_large_data_test);
- g_test_add_func ("/memory_stream/multiple_chunks", do_multiple_chunk_test);
+ g_test_add_func ("/body_stream/large_data", do_large_data_test);
+ g_test_add_func ("/body_stream/multiple_chunks", do_multiple_chunk_test);
ret = g_test_run ();
diff --git a/tests/http2-test.c b/tests/http2-test.c
index a6751e8d..2151ab73 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -20,7 +20,7 @@
#include "test-utils.h"
#include "soup-connection.h"
#include "soup-message-private.h"
-#include "soup-memory-input-stream.h"
+#include "soup-body-input-stream-http2.h"
typedef struct {
SoupSession *session;
@@ -226,8 +226,8 @@ do_post_blocked_async_test (Test *test, gconstpointer data)
{
GMainContext *async_context = g_main_context_ref_thread_default ();
- GInputStream *in_stream = soup_memory_input_stream_new (NULL);
- soup_memory_input_stream_add_data (SOUP_MEMORY_INPUT_STREAM (in_stream), (guint8*)"Part 1 -", 8);
+ GInputStream *in_stream = soup_body_input_stream_http2_new (NULL);
+ soup_body_input_stream_http2_add_data (SOUP_BODY_INPUT_STREAM_HTTP2 (in_stream), (guint8*)"Part 1
-", 8);
test->msg = soup_message_new (SOUP_METHOD_POST, "https://127.0.0.1:5000/echo_post");
soup_message_set_request_body (test->msg, "text/plain", in_stream, 8 + 8);
@@ -239,8 +239,8 @@ do_post_blocked_async_test (Test *test, gconstpointer data)
while (!response) {
// Let it iterate for a bit waiting on blocked data
if (iteration_count-- == 0) {
- soup_memory_input_stream_add_data (SOUP_MEMORY_INPUT_STREAM (in_stream), (guint8*)"
Part 2", 8);
- soup_memory_input_stream_complete (SOUP_MEMORY_INPUT_STREAM (in_stream));
+ soup_body_input_stream_http2_add_data (SOUP_BODY_INPUT_STREAM_HTTP2 (in_stream),
(guint8*)" Part 2", 8);
+ soup_body_input_stream_http2_complete (SOUP_BODY_INPUT_STREAM_HTTP2 (in_stream));
}
g_main_context_iteration (async_context, TRUE);
}
diff --git a/tests/meson.build b/tests/meson.build
index c04146a2..8ff11ca1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -43,11 +43,11 @@ tests = [
['date', true, []],
['forms', true, []],
['header-parsing', true, []],
+ ['http2-body-stream', true, []],
['hsts', true, []],
['hsts-db', true, []],
['logger', true, []],
['misc', true, []],
- ['memory-stream', true, []],
['multipart', true, []],
['no-ssl', true, []],
['ntlm', true, []],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]