What's wrong with leaving auth NULL?
> + }
> + else
> + {
> + auth = g_strdup_printf("%s:%s",purple_proxy_info_get_username
> (gpi),purple_proxy_info_get_password(gpi));
What happens if purple_proxy_info_get_password returns NULL. I fear
the same about purple_proxy_info_get_username, but I guess there is no
point in purple_proxy_get_setup returning something if there's no
user, right?
Otherwise looks good :)
Can you update the patch with these comments?
--
Felipe Contreras
Good point. But not there, it should be freed after it's used here:
header = g_strdup_printf ("POST http://%s/gateway/gateway.dll?%s HTTP/1.1\r\n"
Then it's not needed any more.
--
Felipe Contreras
Codestyle:
/* get proxy auth info and set up proxy auth header */
> + PurpleProxyInfo *gpi = NULL;
Codestyle; declarations go in the beginning of the block. I'll send a
proposal separately.
> + char *tmp = NULL;
> + const char *username = NULL, *password = NULL;
> + gpi = purple_proxy_get_setup(msn_session_get_user_data(conn-
>>session));
> + if (gpi != NULL)
Codestyle:
+ if (gpi)
> + {
> + username = purple_proxy_info_get_username(gpi);
> + password = purple_proxy_info_get_password(gpi);
> + if (username || password)
> + {
> + auth = g_strdup_printf("%s:%s", username ? username : "",
> password ? password : "");
> + tmp = purple_base64_encode((const guchar *)auth, strlen(auth));
> + g_free(auth);
> + auth = g_strdup_printf("Proxy-Authorization: Basic %s\r\n", tmp);
> + g_free(tmp);
> + }
> + }
> +
> session_id = prev->foo_data;
>
> if (session_id)
> @@ -786,6 +805,10 @@ foo_write (PecanNode *conn,
> count);
>
> g_free (params);
> + if (auth)
> + {
> + g_free(auth);
> + }
g_free can receive NULL, no need for the check.
> #ifdef PECAN_DEBUG_HTTP
> pecan_debug ("header=[%s]", header);
> --
> 1.6.0.4
--
Felipe Contreras
---
io/pecan_http_server.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/io/pecan_http_server.c b/io/pecan_http_server.c
index dd98984..4cc7157 100644
--- a/io/pecan_http_server.c
+++ b/io/pecan_http_server.c
@@ -727,6 +727,27 @@ foo_write (PecanNode *conn,
gchar *auth = NULL;
gchar *session_id;
+ /* get proxy auth info and set up proxy auth header */
+ {
+ PurpleProxyInfo *gpi;
+ gpi = purple_proxy_get_setup(msn_session_get_user_data(conn->session));
+ if (gpi)
+ {
+ const char *username, *password;
+ username = purple_proxy_info_get_username(gpi);
+ password = purple_proxy_info_get_password(gpi);
+ if (username || password)
+ {
+ char *tmp;
+ auth = g_strdup_printf("%s:%s", username ? username : "", password ? password : "");
+ tmp = purple_base64_encode((const guchar *)auth, strlen(auth));
+ g_free(auth);
+ auth = g_strdup_printf("Proxy-Authorization: Basic %s\r\n", tmp);
+ g_free(tmp);
+ }
+ }
+ }
+
session_id = prev->foo_data;
if (session_id)
@@ -760,6 +781,7 @@ foo_write (PecanNode *conn,
count);
g_free (params);
+ g_free (auth);
#ifdef PECAN_DEBUG_HTTP
pecan_debug ("header=[%s]", header);
--
1.6.3.3
Since there was no comments I guess it was ok. Pushed, thanks :)
--
Felipe Contreras