Skip to content

Commit 0070a63

Browse files
author
Helperhaps
committed
http delete with body
1 parent 41b5ee7 commit 0070a63

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/cn/jiguang/common/connection/ApacheHttpClient.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.net.ssl.SSLException;
3434
import javax.net.ssl.SSLHandshakeException;
3535
import java.io.*;
36+
import java.net.URI;
3637
import java.net.UnknownHostException;
3738
import java.text.SimpleDateFormat;
3839
import java.util.Date;
@@ -283,11 +284,13 @@ public ResponseWrapper sendDelete(String url, String content)
283284
throws APIConnectionException, APIRequestException {
284285
ResponseWrapper wrapper = new ResponseWrapper();
285286
CloseableHttpResponse response = null;
286-
HttpDelete httpDelete = new HttpDelete(url);
287+
HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url);
287288
try {
288289
httpDelete.setHeader(HttpHeaders.AUTHORIZATION, _authCode);
289290
httpDelete.setHeader("Content-Type", "application/json");
290291
configHttpRequest(httpDelete);
292+
StringEntity params = new StringEntity(StringUtils.notNull(content), CHARSET);
293+
httpDelete.setEntity(params);
291294
response = getHttpClient(url).execute(httpDelete, HttpClientContext.create());
292295
processResponse(response, wrapper);
293296
} catch (IOException e) {
@@ -495,3 +498,17 @@ public void close() {
495498
}
496499
}
497500
}
501+
502+
503+
class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
504+
public static final String METHOD_NAME = "DELETE";
505+
506+
public String getMethod() {
507+
return METHOD_NAME;
508+
}
509+
510+
public HttpDeleteWithBody(final String uri) {
511+
super();
512+
setURI(URI.create(uri));
513+
}
514+
}

0 commit comments

Comments
 (0)