Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding support for HTTP DELETE requests to contain a body.

  • Loading branch information...
commit e4170a7c96813ff7b37974b15c0161bfbba6e522 1 parent 74dc5bc
@toddmazierski toddmazierski authored
View
2  src/main/java/org/browsermob/proxy/http/BrowserMobHttpClient.java
@@ -253,7 +253,7 @@ public BrowserMobHttpRequest newPut(String url) {
public BrowserMobHttpRequest newDelete(String url) {
try {
URI uri = makeUri(url);
- return new BrowserMobHttpRequest(new HttpDelete(uri), this, -1, captureContent);
+ return new BrowserMobHttpRequest(new HttpDeleteWithBody(uri), this, -1, captureContent);
} catch (URISyntaxException e) {
throw reportBadURI(url, "DELETE");
}
View
37 src/main/java/org/browsermob/proxy/http/HttpDeleteWithBody.java
@@ -0,0 +1,37 @@
+package org.browsermob.proxy.http;
+
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import java.net.URI;
+import org.apache.http.annotation.NotThreadSafe;
+
+// Allows for HTTP DELETE requests to contain a body, which the HttpDelete
+// class does not support. Please see:
+// http://stackoverflow.com/a/3820549/581722
+@NotThreadSafe
+public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
+
+ public final static String METHOD_NAME = "DELETE";
+
+ public HttpDeleteWithBody() {
+ super();
+ }
+
+ public HttpDeleteWithBody(final URI uri) {
+ super();
+ setURI(uri);
+ }
+
+ /**
+ * @throws IllegalArgumentException if the uri is invalid.
+ */
+ public HttpDeleteWithBody(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+
+ @Override
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.