httpRequest method

  1. @override
void httpRequest(
  1. String method,
  2. String? url, [
  3. String? data,
  4. Map<String, String>? headers,
])
override

Processes the HTTP request, returning the server's response via the completion callback.

Implementation

@override
void httpRequest(String method, String? url,
    [String? data, Map<String, String>? headers]) {
  // Query CMIS over HTTP
  final uri = Uri.parse(url!);
  if (method == 'GET') {
    _client
        .get(uri, headers: headers!)
        .then(onSuccess, onError: onError)
        .whenComplete(completion);
  } else if (method == 'PUT') {
    _client
        .put(uri, headers: headers!, body: data)
        .then(onSuccess, onError: onError)
        .whenComplete(completion);
  } else if (method == 'POST') {
    _client
        .post(uri, headers: headers!, body: data)
        .then(onSuccess, onError: onError)
        .whenComplete(completion);
  } else if (method == 'HEAD') {
    _client
        .head(uri, headers: headers!)
        .then(onSuccess, onError: onError)
        .whenComplete(completion);
  } else if (method == 'DELETE') {
    _client
        .delete(uri, headers: headers!)
        .then(onSuccess, onError: onError)
        .whenComplete(completion);
  }
}