Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
Fix: handle invalid requests
Browse files Browse the repository at this point in the history
  • Loading branch information
luizmineo committed Oct 12, 2014
1 parent 748210f commit b9e5920
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/src/server_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,19 @@ void _process(UnparsedRequest req, _RequestState state,
_ChainImpl chain, Completer completer) {
runZoned(() {

shelf_io.handleRequest(req.httpRequest, _mainHandler).then((_) {
_logger.finer("Closed request for: ${request.url}");
completer.complete(req.httpRequest.response);
});
try {
shelf_io.handleRequest(req.httpRequest, _mainHandler).then((_) {
_logger.finer("Closed request for: ${request.url}");
completer.complete(req.httpRequest.response);
});
} catch (e) {
//Shelf is throwing synchronous errors for invalid requests
_handleError("Invalid request!", e, logLevel: Level.FINE);
//avoid resource leak
try {
req.httpRequest.response.close();
} catch(e) {}
}

}, zoneValues: {
#request: req,
Expand Down

0 comments on commit b9e5920

Please sign in to comment.