From 29b543a22e03def5dad27e0b2b489176abf70540 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Fri, 28 Feb 2014 00:32:44 +0100 Subject: [PATCH] Set the HTTP proxy via creation info Let the user provide the http proxy during creation, instead of checking environment variables. --- lib/libwebsockets.c | 15 +++------------ lib/libwebsockets.h | 2 ++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 7f9d20eb0..b81a1902a 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1915,7 +1915,6 @@ LWS_VISIBLE struct libwebsocket_context * libwebsocket_create_context(struct lws_context_creation_info *info) { struct libwebsocket_context *context = NULL; - char *p; int n; #ifndef LWS_NO_SERVER int opt = 1; @@ -2075,20 +2074,12 @@ libwebsocket_create_context(struct lws_context_creation_info *info) /* split the proxy ads:port if given */ - p = getenv("http_proxy"); - if (p) { - strncpy(context->http_proxy_address, p, + if (info->http_proxy_address) { + strncpy(context->http_proxy_address, info->http_proxy_address, sizeof(context->http_proxy_address) - 1); context->http_proxy_address[ sizeof(context->http_proxy_address) - 1] = '\0'; - - p = strchr(context->http_proxy_address, ':'); - if (p == NULL) { - lwsl_err("http_proxy needs to be ads:port\n"); - goto bail; - } - *p = '\0'; - context->http_proxy_port = atoi(p + 1); + context->http_proxy_port = info->http_proxy_port; lwsl_notice(" Proxy %s:%u\n", context->http_proxy_address, diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 24856a499..a7c07aaa0 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -938,6 +938,8 @@ struct lws_context_creation_info { const char *ssl_private_key_filepath; const char *ssl_ca_filepath; const char *ssl_cipher_list; + const char *http_proxy_address; + unsigned int http_proxy_port; int gid; int uid; unsigned int options;