mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
Set the HTTP proxy via creation info
Let the user provide the http proxy during creation, instead of checking environment variables.
This commit is contained in:
parent
fce64cda4c
commit
29b543a22e
2 changed files with 5 additions and 12 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue