send method
Sends the request
to the given uri
.
Implementation
Future<Response> send(Uri uri, Request request) async {
final json = await _encode(request.document);
final body = http.Body(json, utf8);
final headers = http.Headers({
'Accept': [mediaType],
if (json.isNotEmpty) 'Content-Type': [mediaType],
...request.headers
});
final url = request.query.isEmpty
? uri
: uri.replace(queryParameters: request.query.toQuery());
final response = await _handler
.handle(http.Request(http.Method(request.method), url, body, headers));
final document = await _decode(response);
return Response(response, document);
}