diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2021-05-12 15:26:20 +0200 |
---|---|---|
committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2021-05-12 15:26:20 +0200 |
commit | 548991d17ce0267c256f4925e06743d7f69c0bb4 (patch) | |
tree | a68f48b595082fcc7bd470bce99aa97326195991 | |
parent | 235160bc0cfb75c98bb3cfde53e166dcb001aa58 (diff) | |
download | libsoup-548991d17ce0267c256f4925e06743d7f69c0bb4.tar.gz |
Move soup_message_setup_body_istream() to soup-session
It's declared in soup-message-private and implemented in
soup-client-message-io-http1, but it's not http1 specific and will be
used by http2 too.
-rw-r--r-- | libsoup/cache/soup-cache.c | 6 | ||||
-rw-r--r-- | libsoup/soup-client-message-io-http1.c | 57 | ||||
-rw-r--r-- | libsoup/soup-message-private.h | 6 | ||||
-rw-r--r-- | libsoup/soup-session-private.h | 6 | ||||
-rw-r--r-- | libsoup/soup-session.c | 49 |
5 files changed, 62 insertions, 62 deletions
diff --git a/libsoup/cache/soup-cache.c b/libsoup/cache/soup-cache.c index 2d78bfab..8dfef003 100644 --- a/libsoup/cache/soup-cache.c +++ b/libsoup/cache/soup-cache.c @@ -737,9 +737,9 @@ soup_cache_send_response (SoupCache *cache, SoupMessage *msg) /* Create the cache stream. */ soup_message_disable_feature (msg, SOUP_TYPE_CACHE); - cache_stream = soup_message_setup_body_istream (body_stream, msg, - priv->session, - SOUP_STAGE_ENTITY_BODY); + cache_stream = soup_session_setup_message_body_input_stream (priv->session, + msg, body_stream, + SOUP_STAGE_ENTITY_BODY); g_object_unref (body_stream); client_stream = soup_cache_client_input_stream_new (cache_stream); diff --git a/libsoup/soup-client-message-io-http1.c b/libsoup/soup-client-message-io-http1.c index b2279a7c..4ade4e1b 100644 --- a/libsoup/soup-client-message-io-http1.c +++ b/libsoup/soup-client-message-io-http1.c @@ -21,7 +21,7 @@ #include "soup-body-output-stream.h" #include "soup-client-input-stream.h" #include "soup-connection.h" -#include "soup-content-processor.h" +#include "soup-session-private.h" #include "content-sniffer/soup-content-sniffer-stream.h" #include "soup-filter-input-stream.h" #include "soup-logger-private.h" @@ -110,55 +110,6 @@ soup_client_message_io_http1_stolen (SoupClientMessageIO *iface) g_object_unref (msg); } -static gint -processing_stage_cmp (gconstpointer a, - gconstpointer b) -{ - SoupProcessingStage stage_a = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR ((gpointer)a)); - SoupProcessingStage stage_b = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR ((gpointer)b)); - - if (stage_a > stage_b) - return 1; - if (stage_a == stage_b) - return 0; - return -1; -} - -GInputStream * -soup_message_setup_body_istream (GInputStream *body_stream, - SoupMessage *msg, - SoupSession *session, - SoupProcessingStage start_at_stage) -{ - GInputStream *istream; - GSList *p, *processors; - - istream = g_object_ref (body_stream); - - processors = soup_session_get_features (session, SOUP_TYPE_CONTENT_PROCESSOR); - processors = g_slist_sort (processors, processing_stage_cmp); - - for (p = processors; p; p = p->next) { - GInputStream *wrapper; - SoupContentProcessor *processor; - - processor = SOUP_CONTENT_PROCESSOR (p->data); - if (soup_message_disables_feature (msg, p->data) || - soup_content_processor_get_processing_stage (processor) < start_at_stage) - continue; - - wrapper = soup_content_processor_wrap_input (processor, istream, msg, NULL); - if (wrapper) { - g_object_unref (istream); - istream = wrapper; - } - } - - g_slist_free (processors); - - return istream; -} - static void request_body_stream_wrote_data_cb (SoupMessage *msg, const void *buffer, @@ -644,9 +595,9 @@ io_read (SoupClientMessageIOHTTP1 *client_io, io->read_encoding, io->read_length); - io->body_istream = soup_message_setup_body_istream (body_istream, msg, - client_io->item->session, - SOUP_STAGE_MESSAGE_BODY); + io->body_istream = soup_session_setup_message_body_input_stream (client_io->item->session, + msg, body_istream, + SOUP_STAGE_MESSAGE_BODY); g_object_unref (body_istream); } diff --git a/libsoup/soup-message-private.h b/libsoup/soup-message-private.h index 71da0aaa..250dac74 100644 --- a/libsoup/soup-message-private.h +++ b/libsoup/soup-message-private.h @@ -10,7 +10,6 @@ #include "soup-message.h" #include "soup-client-message-io.h" #include "auth/soup-auth.h" -#include "soup-content-processor.h" #include "content-sniffer/soup-content-sniffer.h" #include "soup-session.h" @@ -96,11 +95,6 @@ gboolean soup_message_disables_feature (SoupMessage *msg, GList *soup_message_get_disabled_features (SoupMessage *msg); -GInputStream *soup_message_setup_body_istream (GInputStream *body_stream, - SoupMessage *msg, - SoupSession *session, - SoupProcessingStage start_at_stage); - SoupConnection *soup_message_get_connection (SoupMessage *msg); void soup_message_set_connection (SoupMessage *msg, SoupConnection *conn); diff --git a/libsoup/soup-session-private.h b/libsoup/soup-session-private.h index 794d7c7a..bef2f888 100644 --- a/libsoup/soup-session-private.h +++ b/libsoup/soup-session-private.h @@ -7,6 +7,7 @@ #define __SOUP_SESSION_PRIVATE_H__ 1 #include "soup-session.h" +#include "soup-content-processor.h" G_BEGIN_DECLS @@ -22,6 +23,11 @@ void soup_session_cancel_message (SoupSession *session, SoupMessage *soup_session_get_original_message_for_authentication (SoupSession *session, SoupMessage *msg); +GInputStream *soup_session_setup_message_body_input_stream (SoupSession *session, + SoupMessage *msg, + GInputStream *body_stream, + SoupProcessingStage start_at_stage); + G_END_DECLS #endif /* __SOUP_SESSION_PRIVATE_H__ */ diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index d2dccae9..c480aa7f 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -2444,6 +2444,55 @@ soup_session_get_feature_for_message (SoupSession *session, GType feature_type, return feature; } +static gint +processing_stage_cmp (gconstpointer a, + gconstpointer b) +{ + SoupProcessingStage stage_a = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR ((gpointer)a)); + SoupProcessingStage stage_b = soup_content_processor_get_processing_stage (SOUP_CONTENT_PROCESSOR ((gpointer)b)); + + if (stage_a > stage_b) + return 1; + if (stage_a == stage_b) + return 0; + return -1; +} + +GInputStream * +soup_session_setup_message_body_input_stream (SoupSession *session, + SoupMessage *msg, + GInputStream *body_stream, + SoupProcessingStage start_at_stage) +{ + GInputStream *istream; + GSList *p, *processors; + + istream = g_object_ref (body_stream); + + processors = soup_session_get_features (session, SOUP_TYPE_CONTENT_PROCESSOR); + processors = g_slist_sort (processors, processing_stage_cmp); + + for (p = processors; p; p = g_slist_next (p)) { + GInputStream *wrapper; + SoupContentProcessor *processor; + + processor = SOUP_CONTENT_PROCESSOR (p->data); + if (soup_message_disables_feature (msg, p->data) || + soup_content_processor_get_processing_stage (processor) < start_at_stage) + continue; + + wrapper = soup_content_processor_wrap_input (processor, istream, msg, NULL); + if (wrapper) { + g_object_unref (istream); + istream = wrapper; + } + } + + g_slist_free (processors); + + return istream; +} + static void soup_session_class_init (SoupSessionClass *session_class) { |