diff options
author | Milan Crha <mcrha@redhat.com> | 2022-12-07 14:16:28 +0100 |
---|---|---|
committer | Patrick Griffis <pgriffis@igalia.com> | 2023-01-20 19:55:52 +0000 |
commit | 767c61f390840ba5c2c17a7fb3e49551816ceded (patch) | |
tree | e1982b73c2ceda8f19cfbebaa1d4d72f19adf3c1 /libsoup | |
parent | bea49ce848bcfc10d86cbf952f20d43110a6f2a7 (diff) | |
download | libsoup-767c61f390840ba5c2c17a7fb3e49551816ceded.tar.gz |
soup-connection-manager: Read 'SOUP_FORCE_HTTP1' environment variable only once
The environment variables usually do not change during runtime,
it's unexpected even for this semi-debugging variable, thus
let it be read only once and the result being used repeatedly.
Diffstat (limited to 'libsoup')
-rw-r--r-- | libsoup/soup-connection-manager.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libsoup/soup-connection-manager.c b/libsoup/soup-connection-manager.c index d0082981..981a3d30 100644 --- a/libsoup/soup-connection-manager.c +++ b/libsoup/soup-connection-manager.c @@ -378,6 +378,7 @@ static SoupConnection * soup_connection_manager_get_connection_locked (SoupConnectionManager *manager, SoupMessageQueueItem *item) { + static gchar env_force_http1 = -1; SoupMessage *msg = item->msg; gboolean need_new_connection; SoupConnection *conn; @@ -388,6 +389,9 @@ soup_connection_manager_get_connection_locked (SoupConnectionManager *manager, GSocketConnectable *remote_connectable; gboolean try_cleanup = TRUE; + if (env_force_http1 == -1) + env_force_http1 = g_getenv ("SOUP_FORCE_HTTP1") != NULL ? 1 : 0; + need_new_connection = (soup_message_query_flags (msg, SOUP_MESSAGE_NEW_CONNECTION)) || (soup_message_is_misdirected_retry (msg)) || @@ -396,7 +400,7 @@ soup_connection_manager_get_connection_locked (SoupConnectionManager *manager, host = soup_connection_manager_get_or_create_host_for_item (manager, item); - force_http_version = g_getenv ("SOUP_FORCE_HTTP1") ? SOUP_HTTP_1_1 : soup_message_get_force_http_version (msg); + force_http_version = env_force_http1 ? SOUP_HTTP_1_1 : soup_message_get_force_http_version (msg); while (TRUE) { for (l = host->conns; l && l->data; l = g_list_next (l)) { SoupHTTPVersion http_version; |