@@ -331,7 +331,7 @@ void HttpHandler::onMessageComplete() {
331
331
332
332
if (status_code != HTTP_STATUS_NEXT) {
333
333
// keepalive ? Reset : Close
334
- if (keepalive) {
334
+ if (error == 0 && keepalive) {
335
335
Reset ();
336
336
} else {
337
337
state = WANT_CLOSE;
@@ -467,9 +467,9 @@ int HttpHandler::HandleHttpRequest() {
467
467
pResp->status_code = (http_status)status_code;
468
468
if (pResp->status_code >= 400 && pResp->body .size () == 0 && pReq->method != HTTP_HEAD) {
469
469
if (service->errorHandler ) {
470
- customHttpHandler (service->errorHandler );
470
+ status_code = customHttpHandler (service->errorHandler );
471
471
} else {
472
- defaultErrorHandler ();
472
+ status_code = defaultErrorHandler ();
473
473
}
474
474
}
475
475
}
@@ -481,7 +481,10 @@ int HttpHandler::HandleHttpRequest() {
481
481
pResp->headers [" Etag" ] = fc->etag ;
482
482
}
483
483
if (service->postprocessor ) {
484
- customHttpHandler (service->postprocessor );
484
+ status_code = customHttpHandler (service->postprocessor );
485
+ }
486
+ if (status_code == HTTP_STATUS_WANT_CLOSE) {
487
+ error = ERR_REQUEST;
485
488
}
486
489
487
490
if (writer && writer->state != hv::HttpResponseWriter::SEND_BEGIN) {
@@ -853,7 +856,7 @@ int HttpHandler::SendHttpStatusResponse(http_status status_code) {
853
856
if (state > WANT_SEND) return 0 ;
854
857
resp->status_code = status_code;
855
858
addResponseHeaders ();
856
- HandleHttpRequest ();
859
+ if ( HandleHttpRequest () == HTTP_STATUS_NEXT) return 0 ;
857
860
state = WANT_SEND;
858
861
return SendHttpResponse ();
859
862
}
0 commit comments