Skip to content

Commit 50f7742

Browse files
authored
Fix: consume http request on missing handler (#54)
* Fix: consume http request on missing handler * Style: fix comment
1 parent 07d2950 commit 50f7742

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

trpc/server/http_service.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,14 @@ void HttpService::HandleTransportMessage(STransportReqMsg* recv, STransportRspMs
3939
std::string uri_path = trpc::http::NormalizeUrl(req->GetRouteUrlView());
4040

4141
http::HandlerBase* handler = routes_.GetHandler(uri_path, req);
42-
if (!handler) { // 404 Not Found.
43-
Handle(uri_path, handler, context, req, rsp, send);
44-
} else if (!handler->IsStream()) { // Non-streaming handler.
42+
if (!handler || !handler->IsStream()) { // path not found or non-stream handler
4543
Status status = req_stream.AppendToRequest(req->GetMaxBodySize());
4644
if (status.OK()) {
4745
Handle(uri_path, handler, context, req, rsp, send);
4846
} else {
4947
HandleError(context, req, rsp, status);
5048
}
51-
} else { // Streaming handler.
49+
} else { // stream handler
5250
rsp.EnableStream(context.get());
5351
Handle(uri_path, handler, context, req, rsp, send);
5452
rsp.GetStream().Close();

0 commit comments

Comments
 (0)