client redirect: choose correct error path after resetting client connection
https://github.com/warmcat/libwebsockets/issues/810
This commit is contained in:
parent
dc4934d2bc
commit
0db9b9f346
3 changed files with 17 additions and 5 deletions
|
@ -372,10 +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,
|
||||
lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
||||
const char *path, const char *host)
|
||||
{
|
||||
char origin[300] = "", protocol[300] = "", method[32] = "", *p;
|
||||
struct lws *wsi = *pwsi;
|
||||
|
||||
if (wsi->u.hdr.redirects == 3) {
|
||||
lwsl_err("%s: Too many redirects\n", __func__);
|
||||
|
@ -444,7 +445,9 @@ lws_client_reset(struct lws *wsi, int ssl, const char *address, int port,
|
|||
if (lws_hdr_simple_create(wsi, _WSI_TOKEN_CLIENT_URI, origin))
|
||||
return NULL;
|
||||
|
||||
return lws_client_connect_2(wsi);
|
||||
*pwsi = lws_client_connect_2(wsi);
|
||||
|
||||
return *pwsi;
|
||||
}
|
||||
|
||||
#ifdef LWS_WITH_HTTP_PROXY
|
||||
|
|
13
lib/client.c
13
lib/client.c
|
@ -483,10 +483,19 @@ lws_client_interpret_server_handshake(struct lws *wsi)
|
|||
if (!strcmp(prot, "wss") || !strcmp(prot, "https"))
|
||||
ssl = 1;
|
||||
|
||||
if (!lws_client_reset(wsi, ssl, ads, port, path, ads)) {
|
||||
if (!lws_client_reset(&wsi, ssl, ads, port, path, ads)) {
|
||||
/* there are two ways to fail out with NULL return...
|
||||
* simple, early problem where the wsi is intact, or
|
||||
* we went through with the reconnect attempt and the
|
||||
* wsi is already closed. In the latter case, the wsi
|
||||
* has beet set to NULL additionally.
|
||||
*/
|
||||
lwsl_err("Redirect failed\n");
|
||||
cce = "HS: Redirect failed";
|
||||
goto bail3;
|
||||
if (wsi)
|
||||
goto bail3;
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1616,7 +1616,7 @@ LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
|
|||
lws_client_connect_2(struct lws *wsi);
|
||||
|
||||
LWS_VISIBLE struct lws * LWS_WARN_UNUSED_RESULT
|
||||
lws_client_reset(struct lws *wsi, int ssl, const char *address, int port,
|
||||
lws_client_reset(struct lws **wsi, int ssl, const char *address, int port,
|
||||
const char *path, const char *host);
|
||||
|
||||
LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
|
||||
|
|
Loading…
Add table
Reference in a new issue