summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGadkari Mugdha <mugdha.gadkari@siemens.com>2016-06-13 08:43:03 +0200
committerAndy Green <andy@warmcat.com>2016-06-13 17:19:55 +0800
commit8d4c673d02624b5da82cea29b6370c0b6e23d444 (patch)
tree6794f6b9b55eee79ef4268485cc566c2f7b0762d
parent499954a09646e2c7140957ec0244fd26418077b2 (diff)
downloadlibwebsockets-8d4c673d02624b5da82cea29b6370c0b6e23d444.tar.gz
libwebsockets-8d4c673d02624b5da82cea29b6370c0b6e23d444.tar.bz2
libwebsockets-8d4c673d02624b5da82cea29b6370c0b6e23d444.zip
fix for https connection code
-rwxr-xr-x[-rw-r--r--]lib/client.c4
-rwxr-xr-x[-rw-r--r--]lib/libwebsockets.c12
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/client.c b/lib/client.c
index fd7bb186..35fe8a19 100644..100755
--- a/lib/client.c
+++ b/lib/client.c
@@ -868,9 +868,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,
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 3f5760b5..99f8ec12 100644..100755
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -405,10 +405,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");
- context->protocols[0].callback(wsi,
+ errorString = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP);
+ if (errorString) {
+ context->protocols[0].callback(wsi,
+ LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
+ wsi->user_space, errorString,
+ (unsigned int)strlen(errorString));
+ } else {
+ context->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);