delete static method
dynamic
delete(})
Sends an HTTP DELETE request.
Implementation
static delete(String url,
{Map<String, String>? headers,
Object? data,
Map<String, String>? cookies,
int timeout = 10}) async {
http.Response response;
Uri parseUrl = _urlValidator(url);
if (cookies != null) {
if (headers != null) {
headers['Cookie'] = mapToCookie(cookies);
} else {
headers = {'Cookie': mapToCookie(cookies)};
}
}
try {
response = await http
.delete(parseUrl, body: data, headers: headers)
.timeout(Duration(seconds: timeout), onTimeout: () {
throw HttpRequestException(
code: 'TIMEOUT',
message:
'A connection timeout ( The server at $url is taking too long to response. ) The requested site did not response to a connection request and http request has stopped waiting for a reply',
);
});
} on FormatException {
throw HttpRequestException(
code: 'INVALID_URL',
message:
'The requested url is invalid ( Please enter valid url or hostname ).',
);
} catch (e) {
throw HttpRequestException(
code: 'UNREACHABLE',
message:
'A network error (such as interrupted connection or host $url unreachable ) has occurred.',
);
}
return HttpResponse(response);
}