send method

Future<HttpClientResponse> send(
  1. String method,
  2. String path, {
  3. dynamic body,
  4. Map<String, dynamic>? headers,
})

Use this method to send custom HTTP requests to the screen See UpnpCommon.httpClient.openUrl

Implementation

Future<HttpClientResponse> send(String method, String path,
    {body, Map<String, dynamic>? headers}) async {
  final request =
      await UpnpCommon.httpClient.openUrl(method, baseUri.resolve(path));

  if (body is String) {
    request.write(body);
  } else if (body is List<int>) {
    request.add(body);
  }

  if (headers != null) {
    for (String key in headers.keys) {
      request.headers.set(key, headers[key] as Object);
    }
  }

  return await request.close();
}