You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2013/07/14 22:17:22 UTC

svn commit: r1503047 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/

Author: pmouawad
Date: Sun Jul 14 20:17:21 2013
New Revision: 1503047

URL: http://svn.apache.org/r1503047
Log:
Bug 55255 - Allow Body in HTTP DELETE method to support API that use it (like ElasticSearch)
Bugzilla Id: 55255

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1503047&r1=1503046&r2=1503047&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java Sun Jul 14 20:17:21 2013
@@ -219,14 +219,19 @@ public class HTTPHC3Impl extends HTTPHCA
             } else if (method.equals(HTTPConstants.OPTIONS)){
                 httpMethod = new OptionsMethod(urlStr);
             } else if (method.equals(HTTPConstants.DELETE)){
-                httpMethod = new DeleteMethod(urlStr);
+                httpMethod = new EntityEnclosingMethod(urlStr) {
+                    @Override
+                    public String getName() { // HC3.1 does not have the method
+                        return HTTPConstants.DELETE;
+                    }
+                };
             } else if (method.equals(HTTPConstants.GET)){
                 httpMethod = new GetMethod(urlStr);
             } else if (method.equals(HTTPConstants.PATCH)){
                 httpMethod = new EntityEnclosingMethod(urlStr) {
                     @Override
                     public String getName() { // HC3.1 does not have the method
-                        return "PATCH";
+                        return HTTPConstants.PATCH;
                     }
                 };
             } else {
@@ -254,7 +259,8 @@ public class HTTPHC3Impl extends HTTPHCA
             if (method.equals(HTTPConstants.POST)) {
                 String postBody = sendPostData((PostMethod)httpMethod);
                 res.setQueryString(postBody);
-            } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)) {
+            } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH) 
+                    || method.equals(HTTPConstants.DELETE)) {
                 String putBody = sendEntityData((EntityEnclosingMethod) httpMethod);
                 res.setQueryString(putBody);
             }
@@ -959,7 +965,7 @@ public class HTTPHC3Impl extends HTTPHCA
     }
 
     /**
-     * Set up the PUT/PATCH data
+     * Set up the PUT/PATCH/DELETE data
      */
     private String sendEntityData(EntityEnclosingMethod put) throws IOException {
         // Buffer to hold the put body, except file content

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1503047&r1=1503046&r2=1503047&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Sun Jul 14 20:17:21 2013
@@ -55,7 +55,6 @@ import org.apache.http.client.Credential
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
@@ -220,6 +219,19 @@ public class HTTPHC4Impl extends HTTPHCA
         super(testElement);
     }
 
+    public static final class HttpDelete extends HttpEntityEnclosingRequestBase {
+
+        public HttpDelete(final URI uri) {
+            super();
+            setURI(uri);
+        }
+
+        @Override
+        public String getMethod() {
+            return HTTPConstants.DELETE;
+        }
+    }
+    
     @Override
     protected HTTPSampleResult sample(URL url, String method,
             boolean areFollowingRedirect, int frameDepth) {
@@ -380,7 +392,8 @@ public class HTTPHC4Impl extends HTTPHCA
         if (method.equals(HTTPConstants.POST)) {
             String postBody = sendPostData((HttpPost)httpRequest);
             result.setQueryString(postBody);
-        } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)) {
+        } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)
+                || method.equals(HTTPConstants.DELETE)) {
             String entityBody = sendEntityData(( HttpEntityEnclosingRequestBase)httpRequest);
             result.setQueryString(entityBody);
         }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java?rev=1503047&r1=1503046&r2=1503047&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java Sun Jul 14 20:17:21 2013
@@ -135,7 +135,9 @@ public class HTTPSampleResult extends Sa
             sb.append(u.toString());
             sb.append("\n");
             // Include request body if it is a post or put or patch
-            if (HTTPConstants.POST.equals(method) || HTTPConstants.PUT.equals(method) || HTTPConstants.PATCH.equals(method)) {
+            if (HTTPConstants.POST.equals(method) || HTTPConstants.PUT.equals(method) 
+                    || HTTPConstants.PATCH.equals(method)
+                    || HTTPConstants.DELETE.equals(method)) {
                 sb.append("\n"+method+" data:\n");
                 sb.append(queryString);
                 sb.append("\n");

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1503047&r1=1503046&r2=1503047&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jul 14 20:17:21 2013
@@ -238,6 +238,7 @@ Transaction Controller now sets Response
 <h3>HTTP Samplers</h3>
 <ul>
 <li>HTTP Request: Small user interaction improvements in Row parameter Detail Box</li>
+<li><bugzilla>55255</bugzilla> - Allow Body in HTTP DELETE method to support API that use it (like ElasticSearch)</li>
 </ul>
 
 <h3>Other samplers</h3>