From 6a779771f408856221243122de80e15d1b6f9a8e Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 28 Jan 2015 04:15:13 +0800 Subject: [PATCH] Callback with reason LWS_CALLBACK_CLOSED_HTTP when HTTP closed before serve. If the remote HTTP client closes the connection before serving commences, the only notification client code receives is LWS_CALLBACK_WSI_DESTROY. This commit gives LWS_CALLBACK_CLOSED_HTTP as well, as would happen if HTTP serving had already commenced. --- lib/libwebsockets.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 56e7ca59..5a950ca1 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -92,6 +92,10 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context, goto just_kill_connection; } + if (wsi->mode == LWS_CONNMODE_HTTP_SERVING) + context->protocols[0].callback(context, wsi, + LWS_CALLBACK_CLOSED_HTTP, wsi->user_space, NULL, 0); + if (wsi->mode == LWS_CONNMODE_HTTP_SERVING_ACCEPTED) { if (wsi->u.http.fd != LWS_INVALID_FILE) { lwsl_debug("closing http file\n");