1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

client redirect: make sure there is a leading / on path

This commit is contained in:
Andy Green 2017-02-10 11:00:38 +08:00
parent 807313b157
commit 0b3e9e62cb
2 changed files with 10 additions and 7 deletions

View file

@ -372,9 +372,11 @@ failed1:
* host: host header to send to the new server
*/
LWS_VISIBLE struct lws *
lws_client_reset(struct lws *wsi, int ssl, const char *address, int port, const char *path, const char *host)
lws_client_reset(struct lws *wsi, int ssl, const char *address, int port,
const char *path, const char *host)
{
char origin[300] = "", protocol[300] = "", method[32] = "", *p;
if (wsi->u.hdr.redirects == 3) {
lwsl_err("%s: Too many redirects\n", __func__);
return NULL;
@ -402,7 +404,8 @@ lws_client_reset(struct lws *wsi, int ssl, const char *address, int port, const
if (p)
strncpy(method, p, sizeof(method) - 1);
lwsl_notice("redirect ads='%s', port=%d, path='%s', ssl = %d\n", address, port, path, ssl);
lwsl_debug("redirect ads='%s', port=%d, path='%s', ssl = %d\n",
address, port, path, ssl);
/* close the connection by hand */
@ -420,9 +423,6 @@ lws_client_reset(struct lws *wsi, int ssl, const char *address, int port, const
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_PEER_ADDRESS, address))
return NULL;
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_URI, path))
return NULL;
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_HOST, host))
return NULL;
@ -439,6 +439,11 @@ lws_client_reset(struct lws *wsi, int ssl, const char *address, int port, const
method))
return NULL;
origin[0] = '/';
strncpy(&origin[1], path, sizeof(origin) - 2);
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_URI, origin))
return NULL;
return lws_client_connect_2(wsi);
}

View file

@ -483,8 +483,6 @@ lws_client_interpret_server_handshake(struct lws *wsi)
if (!strcmp(prot, "wss") || !strcmp(prot, "https"))
ssl = 1;
lwsl_notice("ssl %d %s\n", ssl, prot);
if (!lws_client_reset(wsi, ssl, ads, port, path, ads)) {
lwsl_err("Redirect failed\n");
cce = "HS: Redirect failed";