send<T> method

  1. @override
Future<Response<T>> send<T>(
  1. Request<T> request
)
override

Sends an HTTP Request.

Implementation

@override
Future<Response<T>> send<T>(Request<T> request) async {
  var requestBody = await request.bodyBytes.toBytes();
  var bodyBytes = BodyBytesStream.fromBytes(requestBody);

  var response = await _handler(request);

  final stringBody = await bodyBytesToString(bodyBytes, response.headers!);

  var mimeType = response.headers!.containsKey('content-type')
      ? response.headers!['content-type']
      : '';

  final body = bodyDecoded<T>(
    request,
    stringBody,
    mimeType,
  );
  return Response(
    headers: response.headers,
    request: request,
    statusCode: response.statusCode,
    statusText: response.statusText,
    bodyBytes: bodyBytes,
    body: body,
    bodyString: stringBody,
  );
}