finalizeRequest method

Future<FinalizedRequest> finalizeRequest([
  1. dynamic body
])
inherited

Freeze this request in preparation of it being sent. This freezes all fields, preventing further unexpected modification, and triggers the creation of a finalized request body.

Implementation

Future<FinalizedRequest> finalizeRequest([dynamic body]) async {
  final finalizedHeaders = finalizeHeaders();
  final finalizedBody = await finalizeBody(body);
  final finalizedRequest = FinalizedRequest(
      method!, uri, finalizedHeaders, finalizedBody, withCredentials);

  if (isSent)
    throw StateError(
        'Request ($this) has already been sent - it cannot be sent again.');
  isSent = true;

  return finalizedRequest;
}