diff --git a/http/server/HttpHandler.cpp b/http/server/HttpHandler.cpp index 005967328..e9136c1c3 100644 --- a/http/server/HttpHandler.cpp +++ b/http/server/HttpHandler.cpp @@ -482,21 +482,25 @@ int HttpHandler::HandleHttpRequest() { } postprocessor: + // Handle HTTP_STATUS_CLOSE: close connection without response + if (status_code == HTTP_STATUS_CLOSE) { + state = WANT_CLOSE; + return HTTP_STATUS_CLOSE; + } if (status_code >= 100 && status_code < 600) { pResp->status_code = (http_status)status_code; if (pResp->status_code >= 400 && pResp->body.size() == 0 && pReq->method != HTTP_HEAD) { if (service->errorHandler) { - status_code = customHttpHandler(service->errorHandler); + int err_status_code = customHttpHandler(service->errorHandler); + if (err_status_code == HTTP_STATUS_CLOSE) { + state = WANT_CLOSE; + return HTTP_STATUS_CLOSE; + } } else { defaultErrorHandler(); } } } - // Handle HTTP_STATUS_CLOSE: close connection without response - if (status_code == HTTP_STATUS_CLOSE) { - state = WANT_CLOSE; - return HTTP_STATUS_CLOSE; - } if (fc) { pResp->content = fc->filebuf.base; pResp->content_length = fc->filebuf.len; @@ -505,8 +509,8 @@ int HttpHandler::HandleHttpRequest() { pResp->headers["Etag"] = fc->etag; } if (service->postprocessor) { - status_code = customHttpHandler(service->postprocessor); - if (status_code == HTTP_STATUS_CLOSE) { + int post_status_code = customHttpHandler(service->postprocessor); + if (post_status_code == HTTP_STATUS_CLOSE) { state = WANT_CLOSE; return HTTP_STATUS_CLOSE; }