request method

  1. @override
Future<HttpResponse> request(
  1. String url, {
  2. String method,
  3. String data,
  4. Map<String, String> headers,
})
override

Implementation

@override
Future<HttpResponse> request(String url,
    {String method, String data, Map<String, String> headers}) async {
  numOutstanding++;
  if (debugPrint != null) debugPrint('HTTP Request: $url');

  http.Client client = clientFactory();
  var uriResponse;
  switch (method) {
    case 'POST':
      uriResponse =
          await client.post(Uri.parse(url), body: data, headers: headers);
      break;

    default:
      uriResponse = await client.get(Uri.parse(url), headers: headers);
      break;
  }

  HttpResponse ret =
      HttpResponse(uriResponse.statusCode, text: uriResponse.body);
  if (debugPrint != null) {
    debugPrint('HTTP Response=${ret.status}: ${ret.text}');
  }
  numOutstanding--;
  return ret;
}