Skip to content

Commit

Permalink
client: move redirects and c_port out of union
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Feb 21, 2017
1 parent 3d6a1e1 commit 3e0006c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/client-handshake.c
Expand Up @@ -31,7 +31,7 @@ lws_client_connect_2(struct lws *wsi)
"CONNECT %s:%u HTTP/1.0\x0d\x0a"
"User-agent: libwebsockets\x0d\x0a",
lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS),
wsi->u.hdr.c_port);
wsi->c_port);

if (wsi->vhost->proxy_basic_auth_token[0])
plen += sprintf((char *)pt->serv_buf + plen,
Expand All @@ -54,10 +54,10 @@ lws_client_connect_2(struct lws *wsi)
#ifdef LWS_USE_IPV6
if (LWS_IPV6_ENABLED(wsi->vhost)) {
memset(&server_addr6, 0, sizeof(struct sockaddr_in6));
server_addr6.sin6_port = htons(wsi->u.hdr.c_port);
server_addr6.sin6_port = htons(wsi->c_port);
} else
#endif
server_addr4.sin_port = htons(wsi->u.hdr.c_port);
server_addr4.sin_port = htons(wsi->c_port);
}

/*
Expand Down Expand Up @@ -285,7 +285,7 @@ lws_client_connect_2(struct lws *wsi)
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS,
wsi->vhost->http_proxy_address))
goto failed;
wsi->u.hdr.c_port = wsi->vhost->http_proxy_port;
wsi->c_port = wsi->vhost->http_proxy_port;

n = send(wsi->sock, (char *)pt->serv_buf, plen,
MSG_NOSIGNAL);
Expand Down Expand Up @@ -379,11 +379,11 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
char origin[300] = "", protocol[300] = "", method[32] = "", *p;
struct lws *wsi = *pwsi;

if (wsi->u.hdr.redirects == 3) {
if (wsi->redirects == 3) {
lwsl_err("%s: Too many redirects\n", __func__);
return NULL;
}
wsi->u.hdr.redirects++;
wsi->redirects++;

#ifdef LWS_OPENSSL_SUPPORT
wsi->use_ssl = ssl;
Expand Down Expand Up @@ -418,7 +418,7 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
wsi->state = LWSS_CLIENT_UNCONNECTED;
wsi->protocol = NULL;
wsi->pending_timeout = NO_PENDING_TIMEOUT;
wsi->u.hdr.c_port = port;
wsi->c_port = port;
wsi->hdr_parsing_completed = 0;
_lws_header_table_reset(wsi->u.hdr.ah);

Expand Down Expand Up @@ -597,7 +597,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i)
wsi->state = LWSS_CLIENT_UNCONNECTED;
wsi->pending_timeout = NO_PENDING_TIMEOUT;
wsi->position_in_fds_table = -1;
wsi->u.hdr.c_port = i->port;
wsi->c_port = i->port;
wsi->vhost = i->vhost;
if (!wsi->vhost)
wsi->vhost = i->context->vhost_list;
Expand Down Expand Up @@ -765,7 +765,7 @@ lws_client_connect_via_info2(struct lws *wsi)
if (lws_ext_cb_all_exts(wsi->context, wsi,
LWS_EXT_CB_CAN_PROXY_CLIENT_CONNECTION,
(void *)stash->address,
wsi->u.hdr.c_port) > 0) {
wsi->c_port) > 0) {
lwsl_client("lws_client_connect: ext handling conn\n");

lws_set_timeout(wsi,
Expand Down
10 changes: 6 additions & 4 deletions lib/private-libwebsockets.h
Expand Up @@ -1085,13 +1085,10 @@ struct _lws_header_related {
enum uri_esc_states ues;
short lextable_pos;
unsigned int current_token_limit;
#ifndef LWS_NO_CLIENT
unsigned short c_port;
#endif

char esc_stash;
char post_literal_equal;
unsigned char parser_state; /* enum lws_token_indexes */
char redirects;
};

#if defined(LWS_WITH_RANGES)
Expand Down Expand Up @@ -1509,6 +1506,10 @@ struct lws {
unsigned int redirect_to_https:1;
#endif

#ifndef LWS_NO_CLIENT
unsigned short c_port;
#endif

/* chars */
#ifndef LWS_NO_EXTENSIONS
unsigned char count_act_ext;
Expand All @@ -1523,6 +1524,7 @@ struct lws {
char pps; /* enum lws_pending_protocol_send */
char tsi; /* thread service index we belong to */
char protocol_interpret_idx;
char redirects;
#ifdef LWS_WITH_CGI
char cgi_channel; /* which of stdin/out/err */
char hdr_state;
Expand Down

0 comments on commit 3e0006c

Please sign in to comment.