diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-09-26 08:42:38 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-09-26 21:45:55 +0800 |
commit | 9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19 (patch) | |
tree | a7c2a01bbf11bce97cde8d5fdc0ecf518f67e4b2 /mail/em-format-html.c | |
parent | e384255d8f999bd77fb7ccee5e57c30b54ea5a56 (diff) | |
download | gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar.gz gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar.bz2 gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar.lz gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar.xz gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.tar.zst gsoc2013-evolution-9773f0a3b8ed4a058d4cd28d0bc4060dbe43da19.zip |
EMFormatHTML: Configure CamelHttpStreams with proxy authpass.
Base64-encode the "USER:PASS" authentication string ourselves and hand
it to camel_http_stream_set_proxy_authpass().
This is so I can kill camel_http_stream_set_proxy().
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r-- | mail/em-format-html.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c index a1be319390..e41455e294 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1511,6 +1511,43 @@ emfh_getpuri (struct _EMFormatHTMLJob *job, } static void +emfh_configure_stream_for_proxy (CamelHttpStream *stream, + const gchar *uri) +{ + EProxy *proxy; + SoupURI *proxy_uri; + gchar *basic; + gchar *basic64; + const gchar *user = ""; + const gchar *password = ""; + + proxy = em_utils_get_proxy (); + + if (!e_proxy_require_proxy_for_uri (proxy, uri)) + return; + + proxy_uri = e_proxy_peek_uri_for (proxy, uri); + + if (proxy_uri == NULL) + return; + + if (proxy_uri->user != NULL) + user = proxy_uri->user; + + if (proxy_uri->password != NULL) + password = proxy_uri->password; + + if (*user == '\0' && *password == '\0') + return; + + basic = g_strdup_printf ("%s:%s", user, password); + basic64 = g_base64_encode ((guchar *) basic, strlen (basic)); + camel_http_stream_set_proxy_authpass (stream, basic64); + g_free (basic64); + g_free (basic); +} + +static void emfh_gethttp (struct _EMFormatHTMLJob *job, GCancellable *cancellable) { @@ -1533,7 +1570,6 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, if (instream == NULL) { EMailImageLoadingPolicy policy; - gchar *proxy; policy = em_format_html_get_image_loading_policy (job->format); @@ -1552,12 +1588,9 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, } instream = camel_http_stream_new (CAMEL_HTTP_METHOD_GET, ((EMFormat *) job->format)->session, url); - camel_http_stream_set_user_agent((CamelHttpStream *)instream, "CamelHttpStream/1.0 Evolution/" VERSION); - proxy = em_utils_get_proxy_uri (job->u.uri); - if (proxy) { - camel_http_stream_set_proxy ((CamelHttpStream *) instream, proxy); - g_free (proxy); - } + camel_http_stream_set_user_agent((CamelHttpStream *) instream, "CamelHttpStream/1.0 Evolution/" VERSION); + emfh_configure_stream_for_proxy ((CamelHttpStream *) instream, job->u.uri); + camel_operation_push_message ( cancellable, _("Retrieving '%s'"), job->u.uri); tmp_stream = (CamelHttpStream *) instream; |