diff options
author | Dan Winship <danw@src.gnome.org> | 2003-06-03 20:38:38 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2003-06-03 20:38:38 +0000 |
commit | 0c5f03a037b5dd4d6761b86e4e4160421f056aac (patch) | |
tree | 315b5295fa37211aaadd74c41f43f2f135a517c8 /libsoup/soup-context.c | |
parent | 514012912dad15272f0788c4ece31fe073f3a318 (diff) | |
download | libsoup-soup-refactoring.tar.gz |
Push SoupContext into the background in preparation for itssoup-refactoring
eventual removal.
* libsoup/soup-message.c (soup_message_new,
soup_message_new_full): Take a SoupUri instead of a SoupContext
(soup_message_set_uri): instead of set_context
(redirect_handler): Use soup_message_set_uri
(soup_message_get_context): gone
* libsoup/soup-context.c (struct _SoupContext): Move this here. No
one else needs to know.
(soup_context_get): Gone
(soup_context_from_uri): constify uri
(get_proxy): moved here from soup-misc.c and made to return a
SoupUri.
(try_create_connection): Update for that.
* libsoup/soup-private.h: Remove struct _SoupContext def
* libsoup/soup-connection.c (soup_connection_new): constify uri
* libsoup/soup-proxy-connection.c (soup_proxy_connection_new):
constify uri arguments, remove SoupContext references
* libsoup/soup-misc.c (soup_get_proxy): Gone
* libsoup/soup-server-cgi.c (run_async): Use soup_message_set_uri, etc
* libsoup/soup-server-tcp.c (read_headers_cb): Likewise
* tests/*: update soup_message_new() calls
Diffstat (limited to 'libsoup/soup-context.c')
-rw-r--r-- | libsoup/soup-context.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/libsoup/soup-context.c b/libsoup/soup-context.c index c5afec61..1235525e 100644 --- a/libsoup/soup-context.c +++ b/libsoup/soup-context.c @@ -33,34 +33,13 @@ #include "soup-ssl.h" #include "soup-www-auth-context.h" -GHashTable *soup_hosts; /* KEY, VALUE: SoupHost */ - -/** - * soup_context_get: - * @uri: the stringified URI. - * - * Returns a pointer to the %SoupContext representing @uri. If a context - * already exists for the URI, it is returned with an added reference. - * Otherwise, a new context is created with a reference count of one. - * - * Return value: a %SoupContext representing @uri. - */ -SoupContext * -soup_context_get (const gchar *uri) -{ - SoupUri *suri; - SoupContext *con; - - g_return_val_if_fail (uri != NULL, NULL); - - suri = soup_uri_new (uri); - if (!suri) return NULL; - - con = soup_context_from_uri (suri); - soup_uri_free (suri); +struct _SoupContext { + SoupUri *uri; + SoupHost *server; + guint refcnt; +}; - return con; -} +GHashTable *soup_hosts; /* KEY, VALUE: SoupHost */ /** * soup_context_uri_hash: @@ -163,7 +142,7 @@ authenticate (SoupAuthContext *ac, SoupAuth *auth, SoupMessage *msg) * Return value: a %SoupContext representing @uri. */ SoupContext * -soup_context_from_uri (SoupUri *suri) +soup_context_from_uri (const SoupUri *suri) { SoupHost *serv = NULL; SoupContext *ret; @@ -348,21 +327,39 @@ try_existing_connections (SoupContext *ctx, return FALSE; } +static const SoupUri * +get_proxy (void) +{ + static SoupUri *proxy = NULL; + static gboolean inited = FALSE; + + if (!inited) { + char *proxy_string; + + proxy_string = getenv ("SOUP_PROXY"); + if (proxy_string) + proxy = soup_uri_new (proxy_string); + inited = TRUE; + } + + return proxy; +} + static gboolean try_create_connection (struct SoupContextConnectData *data) { SoupContext *ctx = data->ctx; - SoupContext *proxy; + const SoupUri *proxy_uri; data->timeout_tag = 0; - proxy = soup_get_proxy (); - if (proxy) { + proxy_uri = get_proxy (); + if (proxy_uri) { data->connection = soup_proxy_connection_new (ctx->uri, ctx->server->ac, - proxy->uri, - proxy->server->ac); + proxy_uri, + NULL); } else { data->connection = soup_connection_new (ctx->uri, ctx->server->ac); |