* 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;
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 */
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;
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);
}
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";