handleRawRequestSafely method

Future<void> handleRawRequestSafely(
  1. Request request,
  2. Response response
)

Like handleRawRequest, but never fails: errors that happen outside the per-request error zone are logged and answered, since left unhandled they would terminate the whole server.

A malformed request that cannot become a RequestContext (a FormatException, or an HttpException from parsing its headers) is answered with 400 Bad Request, and an AngelHttpException with its status code. Any other error is a server bug, answered with 500 Internal Server Error.

Implementation

Future<void> handleRawRequestSafely(Request request, Response response) {
  late Future<void> handled;
  handled = _handleRawRequestSafely(
    request,
    response,
  ).whenComplete(() => _inFlight.remove(handled));
  _inFlight.add(handled);
  return handled;
}