Вы можете сделать запрос DELETE с телом через сокеты, пример Java-кода, который проверяет HTTPRequest и выполняет другой запрос на DELETE с телом:
public static HTTPResponse execute(HTTPRequest request) throws ExecutionException, InterruptedException {
if (request == null) {
throw new IllegalArgumentException("Missing request!");
}
if (request.getMethod() == HTTPMethod.DELETE && request.getPayload() != null && request.getPayload().length > 0) {
URL obj = request.getURL();
SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
try {
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
con.setRequestMethod("DELETE");
for (HTTPHeader httpHeader : request.getHeaders()) {
con.setRequestProperty(httpHeader.getName(), httpHeader.getValue());
}
con.setDoOutput(true);
con.setDoInput(true);
OutputStream out = con.getOutputStream();
out.write(request.getPayload());
out.flush();
out.close();
List<HTTPHeader> responseHeaders = new ArrayList<>();
for (Map.Entry<String, List<String>> stringListEntry : con.getHeaderFields().entrySet()) {
for (String value : stringListEntry.getValue()) {
responseHeaders.add(new HTTPHeader(stringListEntry.getKey(), value));
}
}
return new HTTPResponse(con.getResponseCode(), StreamUtils.getBytes(con.getInputStream()), con.getURL(), responseHeaders);
} catch (IOException e) {
log.severe(e.getMessage());
}
} else {
Future<HTTPResponse> future = URLFetchServiceFactory.getURLFetchService().fetchAsync(request);
return future.get();
}
return null;
}