Skip to content

Commit d57e6d7

Browse files
author
mpv1989
committed
Implement HTTP GET with body
1 parent 32e6aa2 commit d57e6d7

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

src/main/java/com/arangodb/internal/http/HttpCommunication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.http.client.ClientProtocolException;
4141
import org.apache.http.client.config.RequestConfig;
4242
import org.apache.http.client.methods.CloseableHttpResponse;
43-
import org.apache.http.client.methods.HttpDelete;
4443
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
4544
import org.apache.http.client.methods.HttpGet;
4645
import org.apache.http.client.methods.HttpHead;
@@ -256,7 +255,7 @@ private static HttpRequestBase buildHttpRequestBase(
256255
final HttpRequestBase httpRequest;
257256
switch (request.getRequestType()) {
258257
case DELETE:
259-
httpRequest = new HttpDelete(url);
258+
httpRequest = requestWithBody(new HttpDeleteWithBody(url), request);
260259
break;
261260
case GET:
262261
httpRequest = new HttpGet(url);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.internal.http;
22+
23+
import java.net.URI;
24+
25+
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
26+
27+
/**
28+
* @author Mark - mark at arangodb.com
29+
*
30+
*/
31+
public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
32+
public final static String METHOD_NAME = "DELETE";
33+
34+
public HttpDeleteWithBody(final String uri) {
35+
super();
36+
setURI(URI.create(uri));
37+
}
38+
39+
@Override
40+
public String getMethod() {
41+
return METHOD_NAME;
42+
}
43+
44+
}

src/main/java/com/arangodb/internal/util/CURLLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void log(
4848
final ArangoSerialization util) {
4949
final RequestType requestType = request.getRequestType();
5050
final boolean includeBody = (requestType == RequestType.POST || requestType == RequestType.PUT
51-
|| requestType == RequestType.PATCH) && request.getBody() != null;
51+
|| requestType == RequestType.PATCH || requestType == RequestType.DELETE) && request.getBody() != null;
5252
final StringBuilder buffer = new StringBuilder();
5353
if (includeBody) {
5454
buffer.append("\n");

0 commit comments

Comments
 (0)