[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 67364c01fbf43b56420bb88f2780a195129123b8
Author: Patrick Griffis <pgriffis igalia com>
Date: Wed May 12 12:47:07 2021 -0500
fixup! Add initial HTTP2 backend
libsoup/http2/soup-client-message-io-http2.c | 4 +---
libsoup/http2/soup-memory-input-stream.c | 11 ++++++-----
libsoup/http2/soup-memory-input-stream.h | 5 +++--
tests/http2-test.c | 8 ++------
tests/memory-stream-test.c | 12 +++---------
5 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 82b18801..f463a90c 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -407,10 +407,8 @@ on_data_chunk_recv_callback (nghttp2_session *session,
return NGHTTP2_ERR_PAUSE;
SoupMessage *msg = msgdata->msg;
- GBytes *bytes = g_bytes_new (data, len);
g_assert (msgdata->memory_data_istream != NULL);
- soup_memory_input_stream_add_bytes (SOUP_MEMORY_INPUT_STREAM (msgdata->memory_data_istream), bytes);
- g_bytes_unref (bytes);
+ soup_memory_input_stream_add_data (SOUP_MEMORY_INPUT_STREAM (msgdata->memory_data_istream), data,
len);
if (msgdata->state < STATE_READ_DATA_SNIFFED) {
if (soup_message_get_content_sniffer (msg)) {
diff --git a/libsoup/http2/soup-memory-input-stream.c b/libsoup/http2/soup-memory-input-stream.c
index ac9eee52..9d659d1b 100644
--- a/libsoup/http2/soup-memory-input-stream.c
+++ b/libsoup/http2/soup-memory-input-stream.c
@@ -89,18 +89,19 @@ soup_memory_input_stream_new (GPollableInputStream *parent_stream)
}
void
-soup_memory_input_stream_add_bytes (SoupMemoryInputStream *stream,
- GBytes *bytes)
+soup_memory_input_stream_add_data (SoupMemoryInputStream *stream,
+ const guint8 *data,
+ gsize size)
{
SoupMemoryInputStreamPrivate *priv;
g_return_if_fail (SOUP_IS_MEMORY_INPUT_STREAM (stream));
- g_return_if_fail (bytes != NULL);
+ g_return_if_fail (data != NULL);
priv = soup_memory_input_stream_get_instance_private (stream);
- priv->chunks = g_slist_append (priv->chunks, g_bytes_ref (bytes));
- priv->len += g_bytes_get_size (bytes);
+ priv->chunks = g_slist_append (priv->chunks, g_bytes_new (data, size));
+ priv->len += size;
}
static gssize
diff --git a/libsoup/http2/soup-memory-input-stream.h b/libsoup/http2/soup-memory-input-stream.h
index 3a26c1db..96a9b246 100644
--- a/libsoup/http2/soup-memory-input-stream.h
+++ b/libsoup/http2/soup-memory-input-stream.h
@@ -8,8 +8,9 @@ G_DECLARE_FINAL_TYPE (SoupMemoryInputStream, soup_memory_input_stream, SOUP, MEM
GInputStream * soup_memory_input_stream_new (GPollableInputStream *parent_stream);
-void soup_memory_input_stream_add_bytes (SoupMemoryInputStream *stream,
- GBytes *bytes);
+void soup_memory_input_stream_add_data (SoupMemoryInputStream *stream,
+ const guint8 *data,
+ gsize size);
void soup_memory_input_stream_complete (SoupMemoryInputStream *stream);
diff --git a/tests/http2-test.c b/tests/http2-test.c
index fef69cb3..a6751e8d 100644
--- a/tests/http2-test.c
+++ b/tests/http2-test.c
@@ -227,9 +227,7 @@ 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);
- GBytes *bytes = g_bytes_new_static ("Part 1 -", 8);
- soup_memory_input_stream_add_bytes (SOUP_MEMORY_INPUT_STREAM (in_stream), bytes);
- g_bytes_unref (bytes);
+ soup_memory_input_stream_add_data (SOUP_MEMORY_INPUT_STREAM (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);
@@ -241,9 +239,7 @@ 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) {
- bytes = g_bytes_new_static (" Part 2", 8);
- soup_memory_input_stream_add_bytes (SOUP_MEMORY_INPUT_STREAM (in_stream), bytes);
- g_bytes_unref (bytes);
+ 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));
}
g_main_context_iteration (async_context, TRUE);
diff --git a/tests/memory-stream-test.c b/tests/memory-stream-test.c
index b49e7eed..33d39bee 100644
--- a/tests/memory-stream-test.c
+++ b/tests/memory-stream-test.c
@@ -37,9 +37,7 @@ do_large_data_test (void)
while (data_needed > 0) {
// Copy chunk
- GBytes *bytes = g_bytes_new (memory_chunk, CHUNK_SIZE);
- soup_memory_input_stream_add_bytes (mem_stream, bytes);
- g_bytes_unref (bytes);
+ soup_memory_input_stream_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);
@@ -63,12 +61,8 @@ do_multiple_chunk_test (void)
"1234", "5678", "9012", "hell", "owor", "ld..",
};
- for (guint i = 0; i < G_N_ELEMENTS (chunks); ++i) {
- GBytes *bytes = g_bytes_new_static (chunks[i], 4);
- g_assert (g_bytes_get_size (bytes) == 4);
- soup_memory_input_stream_add_bytes (mem_stream, bytes);
- g_bytes_unref (bytes);
- }
+ for (guint i = 0; i < G_N_ELEMENTS (chunks); ++i)
+ soup_memory_input_stream_add_data (mem_stream, 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]