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

client: awaiting header is only a CCE for ws

In the case http client doesn't get a response and closes, currently
it is confused, it reports it as a CLIENT_CONNECTION_ERROR but then
also a CLOSED_CLIENT_HTTP.

Adapt the logic so we only go that way for ws connection... not getting
the server headers means not reaching ESTABLISHED, which makes it a
CCE not a CLOSE.

Also make sure we never issue a CLOSE type callback if we issued a CCE.
This commit is contained in:
Andy Green 2020-09-16 12:24:43 +01:00
parent 64232ddc4c
commit 38b2730ad5

View file

@ -501,7 +501,15 @@ just_kill_connection:
#endif
#if defined(LWS_WITH_CLIENT)
if ((lwsi_state(wsi) == LRS_WAITING_SERVER_REPLY ||
if ((
#if defined(LWS_ROLE_WS)
/*
* If our goal is a ws upgrade, effectively we did not reach
* ESTABLISHED if we did not get the upgrade server reply
*/
(lwsi_state(wsi) == LRS_WAITING_SERVER_REPLY &&
wsi->role_ops == &role_ops_ws) ||
#endif
lwsi_state(wsi) == LRS_WAITING_DNS ||
lwsi_state(wsi) == LRS_WAITING_CONNECT) &&
!wsi->already_did_cce && wsi->a.protocol) {
@ -642,6 +650,13 @@ just_kill_connection:
pro = wsi->a.protocol;
if (wsi->already_did_cce)
/*
* If we handled this by CLIENT_CONNECTION_ERROR, it's
* mutually exclusive with CLOSE
*/
ccb = 0;
#if defined(LWS_WITH_CLIENT)
if (!ccb && (lwsi_state_PRE_CLOSE(wsi) & LWSIFS_NOT_EST) &&
lwsi_role_client(wsi)) {