processRequest static method

Future<HttpRequestBody> processRequest(
  1. HttpRequest request, {
  2. Encoding defaultEncoding = utf8,
})

Process and parse an incoming HttpRequest.

The returned HttpRequestBody contains a response field for accessing the HttpResponse.

See HttpBodyHandler for more info on defaultEncoding.

Implementation

static Future<HttpRequestBody> processRequest(HttpRequest request,
    {Encoding defaultEncoding = utf8}) async {
  try {
    var body = await _process(request, request.headers, defaultEncoding);
    return HttpRequestBody._(request, body);
  } catch (e) {
    // Try to send BAD_REQUEST response.
    request.response.statusCode = HttpStatus.badRequest;
    await request.response.close();
    rethrow;
  }
}