mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
client: lws_client_reset option to keep ws
With this, ws connection to https://libwebsockets.org/redir-testserver (which redirects to https://libwebsockets.org/testserver) can work OK. https://github.com/warmcat/libwebsockets/issues/1820
This commit is contained in:
parent
bc0ab4b656
commit
e9c8cee5d5
3 changed files with 16 additions and 3 deletions
|
@ -1102,7 +1102,7 @@ lws_client_connect_2_dnsreq(struct lws *wsi);
|
|||
|
||||
LWS_VISIBLE struct lws * LWS_WARN_UNUSED_RESULT
|
||||
lws_client_reset(struct lws **wsi, int ssl, const char *address, int port,
|
||||
const char *path, const char *host);
|
||||
const char *path, const char *host, char weak);
|
||||
|
||||
LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
|
||||
lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi);
|
||||
|
|
|
@ -959,8 +959,11 @@ static uint8_t hnames2[] = {
|
|||
*/
|
||||
struct lws *
|
||||
lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
||||
const char *path, const char *host)
|
||||
const char *path, const char *host, char weak)
|
||||
{
|
||||
#if defined(LWS_ROLE_WS)
|
||||
struct _lws_websocket_related *ws;
|
||||
#endif
|
||||
char *stash, *p;
|
||||
struct lws *wsi;
|
||||
size_t size = 0;
|
||||
|
@ -1041,7 +1044,17 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
|||
address, port, path, ssl, wsi->position_in_fds_table);
|
||||
|
||||
__remove_wsi_socket_from_fds(wsi);
|
||||
#if defined(LWS_ROLE_WS)
|
||||
if (weak) {
|
||||
ws = wsi->ws;
|
||||
wsi->ws = NULL;
|
||||
}
|
||||
#endif
|
||||
__lws_reset_wsi(wsi); /* detaches ah here */
|
||||
#if defined(LWS_ROLE_WS)
|
||||
if (weak)
|
||||
wsi->ws = ws;
|
||||
#endif
|
||||
wsi->client_pipeline = 1;
|
||||
|
||||
/* close the connection by hand */
|
||||
|
|
|
@ -893,7 +893,7 @@ lws_client_interpret_server_handshake(struct lws *wsi)
|
|||
goto bail3;
|
||||
}
|
||||
|
||||
if (!lws_client_reset(&wsi, ssl, ads, port, path, ads)) {
|
||||
if (!lws_client_reset(&wsi, ssl, ads, port, path, ads, 1)) {
|
||||
/*
|
||||
* There are two ways to fail out with NULL return...
|
||||
* simple, early problem where the wsi is intact, or
|
||||
|
|
Loading…
Add table
Reference in a new issue