From e049a77775409910a0ae36de9940d5a13a793537 Mon Sep 17 00:00:00 2001 From: Craig McQueen Date: Thu, 20 Feb 2014 10:27:11 +1100 Subject: [PATCH] Call libwebsocket_set_timeout() before callback LWS_CALLBACK_HTTP. This allows the LWS_CALLBACK_HTTP callback to override the timeout with libwebsocket_set_timeout() if it wants. --- lib/handshake.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/handshake.c b/lib/handshake.c index 35c6e4d..f45ee53 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -256,10 +256,20 @@ http_postbody: LWS_CALLBACK_FILTER_HTTP_CONNECTION, wsi->user_space, uri_ptr, uri_len); - if (!n && wsi->protocol->callback) - n = wsi->protocol->callback(context, wsi, - LWS_CALLBACK_HTTP, - wsi->user_space, uri_ptr, uri_len); + if (!n) { + /* + * if there is content supposed to be coming, + * put a timeout on it having arrived + */ + libwebsocket_set_timeout(wsi, + PENDING_TIMEOUT_HTTP_CONTENT, + AWAITING_TIMEOUT); + + if (wsi->protocol->callback) + n = wsi->protocol->callback(context, wsi, + LWS_CALLBACK_HTTP, + wsi->user_space, uri_ptr, uri_len); + } leave: /* now drop the header info we kept a pointer to */ @@ -274,14 +284,6 @@ leave: } /* - * if there is content supposed to be coming, - * put a timeout on it having arrived - */ - libwebsocket_set_timeout(wsi, - PENDING_TIMEOUT_HTTP_CONTENT, - AWAITING_TIMEOUT); - - /* * (if callback didn't start sending a file) * deal with anything else as body, whether * there was a content-length or not -- 2.7.4