fix for https connection code

This commit is contained in:
Gadkari Mugdha 2016-06-13 17:20:27 +08:00 committed by Andy Green
parent 27b7055ac6
commit c1e14e7f6c
2 changed files with 12 additions and 4 deletions

4
lib/client.c Normal file → Executable file
View file

@ -837,9 +837,7 @@ bail3:
close_reason = LWS_CLOSE_STATUS_NOSTATUS;
bail2:
if (wsi->protocol &&
(wsi->state == LWSS_ESTABLISHED ||
wsi->state == LWSS_CLIENT_UNCONNECTED)) {
if (wsi->protocol && wsi->state == LWSS_ESTABLISHED) {
if (isErrorCodeReceived && p) {
wsi->protocol->callback(wsi,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,

12
lib/libwebsockets.c Normal file → Executable file
View file

@ -487,10 +487,20 @@ just_kill_connection:
wsi->user_space, NULL, 0 );
} else if (wsi->mode == LWSCM_WSCL_WAITING_SERVER_REPLY ||
wsi->mode == LWSCM_WSCL_WAITING_CONNECT) {
char* errorString;
lwsl_debug("Connection closed before server reply\n");
wsi->vhost->protocols[0].callback(wsi,
errorString = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP);
if (errorString) {
wsi->vhost->protocols[0].callback(wsi,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
wsi->user_space, errorString,
(unsigned int)strlen(errorString));
} else {
wsi->vhost->protocols[0].callback(wsi,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
wsi->user_space, NULL, 0);
}
} else
lwsl_debug("not calling back closed mode=%d state=%d\n",
wsi->mode, wsi->state_pre_close);