You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2016/03/03 21:55:34 UTC

svn commit: r1733521 - in /jmeter/trunk: bin/ src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/usermanual/

Author: fschumacher
Date: Thu Mar  3 20:55:33 2016
New Revision: 1733521

URL: http://svn.apache.org/viewvc?rev=1733521&view=rev
Log:
HTTP Request : Make Method field editable so that additional methods (Webdav) can be added easily

Bugzilla Id: 59083

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.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/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1733521&r1=1733520&r2=1733521&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Thu Mar  3 20:55:33 2016
@@ -987,6 +987,9 @@ beanshell.server.file=../extras/startup.
 # default to false
 #httpsampler.embedded_resources_use_md5=false
 
+# List of extra HTTP methods that should be available in select box
+#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
+
 # The encoding to be used if none is provided (default ISO-8859-1)
 #sampleresult.default.encoding=ISO-8859-1
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1733521&r1=1733520&r2=1733521&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java Thu Mar  3 20:55:33 2016
@@ -627,7 +627,7 @@ public class UrlConfigGui extends JPanel
 
         if (notConfigOnly){
             method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
-                    HTTPSamplerBase.getValidMethodsAsArray());
+                    HTTPSamplerBase.getValidMethodsAsArray(), true);
             method.addChangeListener(this);
         }
 

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=1733521&r1=1733520&r2=1733521&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 Thu Mar  3 20:55:33 2016
@@ -487,13 +487,11 @@ public class HTTPHC4Impl extends HTTPHCA
     protected void handleMethod(String method, HTTPSampleResult result,
             HttpRequestBase httpRequest, HttpContext localContext) throws IOException {
         // Handle the various methods
-        if (method.equals(HTTPConstants.POST)) {
+        if (httpRequest instanceof HttpPost) {
             String postBody = sendPostData((HttpPost)httpRequest);
             result.setQueryString(postBody);
-        } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)
-                || HttpWebdav.isWebdavMethod(method)
-                || method.equals(HTTPConstants.DELETE)) {
-            String entityBody = sendEntityData(( HttpEntityEnclosingRequestBase)httpRequest);
+        } else if (httpRequest instanceof HttpEntityEnclosingRequestBase) {
+            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=1733521&r1=1733520&r2=1733521&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 Thu Mar  3 20:55:33 2016
@@ -22,7 +22,10 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
 import org.apache.jmeter.samplers.SampleResult;
@@ -35,6 +38,12 @@ public class HTTPSampleResult extends Sa
 
     private static final long serialVersionUID = 240L;
 
+    /** Set of all HTTP methods, that have no body */
+    private static final Set<String> METHODS_WITHOUT_BODY = new HashSet<>(
+            Arrays.asList(HTTPConstants.GET, HTTPConstants.HEAD,
+                    HTTPConstants.OPTIONS, HTTPConstants.DELETE,
+                    HTTPConstants.TRACE));
+
     private String cookies = ""; // never null
 
     private String method;
@@ -138,10 +147,7 @@ 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)
-                    || HttpWebdav.isWebdavMethod(method)
-                    || HTTPConstants.DELETE.equals(method)) {
+            if (!METHODS_WITHOUT_BODY.contains(method)) {
                 sb.append("\n"+method+" data:\n");
                 sb.append(queryString);
                 sb.append("\n");

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1733521&r1=1733520&r2=1733521&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Thu Mar  3 20:55:33 2016
@@ -226,29 +226,36 @@ public abstract class HTTPSamplerBase ex
     }
 
     public static final String DEFAULT_METHOD = HTTPConstants.GET; // $NON-NLS-1$
-    // Supported methods:
-    private static final String [] METHODS = {
-        DEFAULT_METHOD, // i.e. GET
-        HTTPConstants.POST,
-        HTTPConstants.HEAD,
-        HTTPConstants.PUT,
-        HTTPConstants.OPTIONS,
-        HTTPConstants.TRACE,
-        HTTPConstants.DELETE,
-        HTTPConstants.PATCH,
-        HTTPConstants.PROPFIND,
-        HTTPConstants.PROPPATCH,
-        HTTPConstants.MKCOL,
-        HTTPConstants.COPY,
-        HTTPConstants.MOVE,
-        HTTPConstants.LOCK,
-        HTTPConstants.UNLOCK,
-        HTTPConstants.REPORT,
-        HTTPConstants.MKCALENDAR,
-        HTTPConstants.SEARCH
-        };
 
-    private static final List<String> METHODLIST = Collections.unmodifiableList(Arrays.asList(METHODS));
+    private static final List<String> METHODLIST;
+    static {
+        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
+            DEFAULT_METHOD, // i.e. GET
+            HTTPConstants.POST,
+            HTTPConstants.HEAD,
+            HTTPConstants.PUT,
+            HTTPConstants.OPTIONS,
+            HTTPConstants.TRACE,
+            HTTPConstants.DELETE,
+            HTTPConstants.PATCH,
+            HTTPConstants.PROPFIND,
+            HTTPConstants.PROPPATCH,
+            HTTPConstants.MKCOL,
+            HTTPConstants.COPY,
+            HTTPConstants.MOVE,
+            HTTPConstants.LOCK,
+            HTTPConstants.UNLOCK,
+            HTTPConstants.REPORT,
+            HTTPConstants.MKCALENDAR,
+            HTTPConstants.SEARCH
+        ));
+        String userDefinedMethods = JMeterUtils.getPropDefault(
+                "httpsampler.user_defined_methods", "");
+        if (StringUtils.isNotBlank(userDefinedMethods)) {
+            defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
+        }
+        METHODLIST = Collections.unmodifiableList(defaultMethods);
+    }
 
     // @see mergeFileProperties
     // Must be private, as the file list needs special handling

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java?rev=1733521&r1=1733520&r2=1733521&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java Thu Mar  3 20:55:33 2016
@@ -19,38 +19,25 @@
 package org.apache.jmeter.protocol.http.sampler;
 
 import java.net.URI;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.jmeter.protocol.http.util.HTTPConstants;
 
 /**
  * WebDav request
+ *
  * @since 2.12
  */
 public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
-    private static final Set<String> WEBDAV_METHODS =
-            new HashSet<>(Arrays.asList(
-                    HTTPConstants.PROPFIND,
-                    HTTPConstants.PROPPATCH,
-                    HTTPConstants.MKCOL,
-                    HTTPConstants.COPY,
-                    HTTPConstants.MOVE,
-                    HTTPConstants.LOCK,
-                    HTTPConstants.UNLOCK,
-                    HTTPConstants.REPORT,
-                    HTTPConstants.MKCALENDAR,
-                    HTTPConstants.SEARCH
-            ));
-    
-    private String davMethod;
+
+    private final String davMethod;
 
     /**
      * 
-     * @param davMethod method to use (has to be a Webdav method as identified by {@link #isWebdavMethod(String)})
-     * @param uri {@link URI} to use
+     * @param davMethod
+     *            method to use (has to be a Webdav method as identified by
+     *            {@link #isWebdavMethod(String)})
+     * @param uri
+     *            {@link URI} to use
      */
     public HttpWebdav(final String davMethod, final URI uri) {
         super();
@@ -64,10 +51,13 @@ public final class HttpWebdav extends Ht
     }
 
     /**
-     * @param method Http Method
+     * @param method
+     *            Http Method
      * @return <code>true</code> if method is a Webdav one
      */
     public static boolean isWebdavMethod(String method) {
-        return WEBDAV_METHODS.contains(method);
+        // A HTTP method can be a token as specified in
+        // https://tools.ietf.org/html/rfc7230#section-3.2.6
+        return method != null && method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
     }
 }

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733521&r1=1733520&r2=1733521&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Mar  3 20:55:33 2016
@@ -232,7 +232,10 @@ https.default.protocol=SSLv3
           <code>JAVA</code> implementation). With <code>HttpClient4</code>, the following methods related to WebDav are
           also allowed: <code>COPY</code>, <code>LOCK</code>, <code>MKCOL</code>, <code>MOVE</code>,
           <code>PROPFIND</code>, <code>PROPPATCH</code>, <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
-          <code>SEARCH</code>.</property>
+          <code>SEARCH</code>.
+          <p>More methods can be pre-defined for the HttpClient4 by using the JMeter property
+            <code>httpsampler.user_defined_methods</code>.</p>
+        </property>
         <property name="Content Encoding" required="No">
         Content encoding to be used (for <code>POST</code>, <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
         This is the character encoding to be used, and is not related to the Content-Encoding HTTP header.



Re: svn commit: r1733521 - in /jmeter/trunk: bin/ src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/usermanual/

Posted by Philippe Mouawad <ph...@gmail.com>.
Ho Felix,
My answers below.


On Monday, March 7, 2016, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Am 03.03.2016 um 22:05 schrieb Philippe Mouawad:
>
>> Hi Felix,
>> Sorry for not answering , didn't have time to look at it.
>>
> Sorry for my late reply :)



>
>> Regarding this commit, what about HttpJavaImpl and HC3 ?
>>
> HC3 seems easy to add. I think I will give it a try. Java seems to be out
> of game, if I read the javadoc correctly.


We deprecate it in this release do you think it is still useful to enhance
it ?


>
>
>> Looking into code, it appears anyway Java does not handle Webdav, nor
>> patch. I am also not sure about methods different from POST/GET/PUT.
>>
>
> https://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html#setRequestMethod%28java.lang.String%29
> says GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE are valid methods. I
> will change our documentation to reflect these values.


but does our implementation really works fine with all these ?


>
>> Do you think we should make select box depend on chosen implementation ?
>> knowing it can be:
>> - In HTTP Requrest : Easy to test
>> - A property : Easy to test
>> - HTTP Request Default : More difficult
>>
> I don't think it should be handled differently.


Did you also see my proposal to deprecate Java impl ?

>
> Regards,
>  Felix
>
>
>> For HC3, as we deprecate it it's ok for me.
>>
>> Should we also deprecate JavaImpl ?
>>
>> Regards
>>
>>
>>
>> On Thu, Mar 3, 2016 at 9:55 PM, <fs...@apache.org> wrote:
>>
>> Author: fschumacher
>>> Date: Thu Mar  3 20:55:33 2016
>>> New Revision: 1733521
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1733521&view=rev
>>> Log:
>>> HTTP Request : Make Method field editable so that additional methods
>>> (Webdav) can be added easily
>>>
>>> Bugzilla Id: 59083
>>>
>>> Modified:
>>>      jmeter/trunk/bin/jmeter.properties
>>>
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.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/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>>
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>>      jmeter/trunk/xdocs/usermanual/component_reference.xml
>>>
>>> Modified: jmeter/trunk/bin/jmeter.properties
>>> URL:
>>>
>>> http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1733521&r1=1733520&r2=1733521&view=diff
>>>
>>>
>>> ==============================================================================
>>> --- jmeter/trunk/bin/jmeter.properties (original)
>>> +++ jmeter/trunk/bin/jmeter.properties Thu Mar  3 20:55:33 2016
>>> @@ -987,6 +987,9 @@ beanshell.server.file=../extras/startup.
>>>   # default to false
>>>   #httpsampler.embedded_resources_use_md5=false
>>>
>>> +# List of extra HTTP methods that should be available in select box
>>>
>>>
>>> +#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
>>> +
>>>   # The encoding to be used if none is provided (default ISO-8859-1)
>>>   #sampleresult.default.encoding=ISO-8859-1
>>>
>>>
>>> Modified:
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>>> URL:
>>>
>>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>>
>>>
>>> ==============================================================================
>>> ---
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>>> (original)
>>> +++
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>>> Thu Mar  3 20:55:33 2016
>>> @@ -627,7 +627,7 @@ public class UrlConfigGui extends JPanel
>>>
>>>           if (notConfigOnly){
>>>               method = new
>>> JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
>>> -                    HTTPSamplerBase.getValidMethodsAsArray());
>>> +                    HTTPSamplerBase.getValidMethodsAsArray(), true);
>>>               method.addChangeListener(this);
>>>           }
>>>
>>>
>>> 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=1733521&r1=1733520&r2=1733521&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
>>> Thu Mar  3 20:55:33 2016
>>> @@ -487,13 +487,11 @@ public class HTTPHC4Impl extends HTTPHCA
>>>       protected void handleMethod(String method, HTTPSampleResult result,
>>>               HttpRequestBase httpRequest, HttpContext localContext)
>>> throws
>>> IOException {
>>>           // Handle the various methods
>>> -        if (method.equals(HTTPConstants.POST)) {
>>> +        if (httpRequest instanceof HttpPost) {
>>>               String postBody = sendPostData((HttpPost)httpRequest);
>>>               result.setQueryString(postBody);
>>> -        } else if (method.equals(HTTPConstants.PUT) ||
>>> method.equals(HTTPConstants.PATCH)
>>> -                || HttpWebdav.isWebdavMethod(method)
>>> -                || method.equals(HTTPConstants.DELETE)) {
>>> -            String entityBody = sendEntityData((
>>> HttpEntityEnclosingRequestBase)httpRequest);
>>> +        } else if (httpRequest instanceof
>>> HttpEntityEnclosingRequestBase)
>>> {
>>> +            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=1733521&r1=1733520&r2=1733521&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
>>> Thu Mar  3 20:55:33 2016
>>> @@ -22,7 +22,10 @@ import java.net.HttpURLConnection;
>>>   import java.net.URL;
>>>   import java.nio.charset.Charset;
>>>   import java.util.ArrayList;
>>> +import java.util.Arrays;
>>> +import java.util.HashSet;
>>>   import java.util.List;
>>> +import java.util.Set;
>>>
>>>   import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>>   import org.apache.jmeter.samplers.SampleResult;
>>> @@ -35,6 +38,12 @@ public class HTTPSampleResult extends Sa
>>>
>>>       private static final long serialVersionUID = 240L;
>>>
>>> +    /** Set of all HTTP methods, that have no body */
>>> +    private static final Set<String> METHODS_WITHOUT_BODY = new
>>> HashSet<>(
>>> +            Arrays.asList(HTTPConstants.GET, HTTPConstants.HEAD,
>>> +                    HTTPConstants.OPTIONS, HTTPConstants.DELETE,
>>> +                    HTTPConstants.TRACE));
>>> +
>>>       private String cookies = ""; // never null
>>>
>>>       private String method;
>>> @@ -138,10 +147,7 @@ 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)
>>> -                    || HttpWebdav.isWebdavMethod(method)
>>> -                    || HTTPConstants.DELETE.equals(method)) {
>>> +            if (!METHODS_WITHOUT_BODY.contains(method)) {
>>>                   sb.append("\n"+method+" data:\n");
>>>                   sb.append(queryString);
>>>                   sb.append("\n");
>>>
>>> Modified:
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>> URL:
>>>
>>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>>
>>>
>>> ==============================================================================
>>> ---
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>> (original)
>>> +++
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>> Thu Mar  3 20:55:33 2016
>>> @@ -226,29 +226,36 @@ public abstract class HTTPSamplerBase ex
>>>       }
>>>
>>>       public static final String DEFAULT_METHOD = HTTPConstants.GET; //
>>> $NON-NLS-1$
>>> -    // Supported methods:
>>> -    private static final String [] METHODS = {
>>> -        DEFAULT_METHOD, // i.e. GET
>>> -        HTTPConstants.POST,
>>> -        HTTPConstants.HEAD,
>>> -        HTTPConstants.PUT,
>>> -        HTTPConstants.OPTIONS,
>>> -        HTTPConstants.TRACE,
>>> -        HTTPConstants.DELETE,
>>> -        HTTPConstants.PATCH,
>>> -        HTTPConstants.PROPFIND,
>>> -        HTTPConstants.PROPPATCH,
>>> -        HTTPConstants.MKCOL,
>>> -        HTTPConstants.COPY,
>>> -        HTTPConstants.MOVE,
>>> -        HTTPConstants.LOCK,
>>> -        HTTPConstants.UNLOCK,
>>> -        HTTPConstants.REPORT,
>>> -        HTTPConstants.MKCALENDAR,
>>> -        HTTPConstants.SEARCH
>>> -        };
>>>
>>> -    private static final List<String> METHODLIST =
>>> Collections.unmodifiableList(Arrays.asList(METHODS));
>>> +    private static final List<String> METHODLIST;
>>> +    static {
>>> +        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
>>> +            DEFAULT_METHOD, // i.e. GET
>>> +            HTTPConstants.POST,
>>> +            HTTPConstants.HEAD,
>>> +            HTTPConstants.PUT,
>>> +            HTTPConstants.OPTIONS,
>>> +            HTTPConstants.TRACE,
>>> +            HTTPConstants.DELETE,
>>> +            HTTPConstants.PATCH,
>>> +            HTTPConstants.PROPFIND,
>>> +            HTTPConstants.PROPPATCH,
>>> +            HTTPConstants.MKCOL,
>>> +            HTTPConstants.COPY,
>>> +            HTTPConstants.MOVE,
>>> +            HTTPConstants.LOCK,
>>> +            HTTPConstants.UNLOCK,
>>> +            HTTPConstants.REPORT,
>>> +            HTTPConstants.MKCALENDAR,
>>> +            HTTPConstants.SEARCH
>>> +        ));
>>> +        String userDefinedMethods = JMeterUtils.getPropDefault(
>>> +                "httpsampler.user_defined_methods", "");
>>> +        if (StringUtils.isNotBlank(userDefinedMethods)) {
>>> +
>>>
>>> defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
>>> +        }
>>> +        METHODLIST = Collections.unmodifiableList(defaultMethods);
>>> +    }
>>>
>>>       // @see mergeFileProperties
>>>       // Must be private, as the file list needs special handling
>>>
>>> Modified:
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>> URL:
>>>
>>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>>
>>>
>>> ==============================================================================
>>> ---
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>> (original)
>>> +++
>>>
>>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>> Thu Mar  3 20:55:33 2016
>>> @@ -19,38 +19,25 @@
>>>   package org.apache.jmeter.protocol.http.sampler;
>>>
>>>   import java.net.URI;
>>> -import java.util.Arrays;
>>> -import java.util.HashSet;
>>> -import java.util.Set;
>>>
>>>   import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
>>> -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>>
>>>   /**
>>>    * WebDav request
>>> + *
>>>    * @since 2.12
>>>    */
>>>   public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
>>> -    private static final Set<String> WEBDAV_METHODS =
>>> -            new HashSet<>(Arrays.asList(
>>> -                    HTTPConstants.PROPFIND,
>>> -                    HTTPConstants.PROPPATCH,
>>> -                    HTTPConstants.MKCOL,
>>> -                    HTTPConstants.COPY,
>>> -                    HTTPConstants.MOVE,
>>> -                    HTTPConstants.LOCK,
>>> -                    HTTPConstants.UNLOCK,
>>> -                    HTTPConstants.REPORT,
>>> -                    HTTPConstants.MKCALENDAR,
>>> -                    HTTPConstants.SEARCH
>>> -            ));
>>> -
>>> -    private String davMethod;
>>> +
>>> +    private final String davMethod;
>>>
>>>       /**
>>>        *
>>> -     * @param davMethod method to use (has to be a Webdav method as
>>> identified by {@link #isWebdavMethod(String)})
>>> -     * @param uri {@link URI} to use
>>> +     * @param davMethod
>>> +     *            method to use (has to be a Webdav method as identified
>>> by
>>> +     *            {@link #isWebdavMethod(String)})
>>> +     * @param uri
>>> +     *            {@link URI} to use
>>>        */
>>>       public HttpWebdav(final String davMethod, final URI uri) {
>>>           super();
>>> @@ -64,10 +51,13 @@ public final class HttpWebdav extends Ht
>>>       }
>>>
>>>       /**
>>> -     * @param method Http Method
>>> +     * @param method
>>> +     *            Http Method
>>>        * @return <code>true</code> if method is a Webdav one
>>>        */
>>>       public static boolean isWebdavMethod(String method) {
>>> -        return WEBDAV_METHODS.contains(method);
>>> +        // A HTTP method can be a token as specified in
>>> +        // https://tools.ietf.org/html/rfc7230#section-3.2.6
>>> +        return method != null &&
>>> method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
>>>       }
>>>   }
>>>
>>> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
>>> URL:
>>>
>>> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733521&r1=1733520&r2=1733521&view=diff
>>>
>>>
>>> ==============================================================================
>>> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
>>> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Mar  3
>>> 20:55:33 2016
>>> @@ -232,7 +232,10 @@ https.default.protocol=SSLv3
>>>             <code>JAVA</code> implementation). With
>>> <code>HttpClient4</code>, the following methods related to WebDav are
>>>             also allowed: <code>COPY</code>, <code>LOCK</code>,
>>> <code>MKCOL</code>, <code>MOVE</code>,
>>>             <code>PROPFIND</code>, <code>PROPPATCH</code>,
>>> <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
>>> -          <code>SEARCH</code>.</property>
>>> +          <code>SEARCH</code>.
>>> +          <p>More methods can be pre-defined for the HttpClient4 by
>>> using
>>> the JMeter property
>>> +            <code>httpsampler.user_defined_methods</code>.</p>
>>> +        </property>
>>>           <property name="Content Encoding" required="No">
>>>           Content encoding to be used (for <code>POST</code>,
>>> <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
>>>           This is the character encoding to be used, and is not related
>>> to
>>> the Content-Encoding HTTP header.
>>>
>>>
>>>
>>>
>>
>

-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1733521 - in /jmeter/trunk: bin/ src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/usermanual/

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 03.03.2016 um 22:05 schrieb Philippe Mouawad:
> Hi Felix,
> Sorry for not answering , didn't have time to look at it.
Sorry for my late reply :)
>
> Regarding this commit, what about HttpJavaImpl and HC3 ?
HC3 seems easy to add. I think I will give it a try. Java seems to be 
out of game, if I read the javadoc correctly.

>
> Looking into code, it appears anyway Java does not handle Webdav, nor
> patch. I am also not sure about methods different from POST/GET/PUT.
https://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html#setRequestMethod%28java.lang.String%29
says GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE are valid methods. I 
will change our documentation to reflect these values.
>
> Do you think we should make select box depend on chosen implementation ?
> knowing it can be:
> - In HTTP Requrest : Easy to test
> - A property : Easy to test
> - HTTP Request Default : More difficult
I don't think it should be handled differently.

Regards,
  Felix

>
> For HC3, as we deprecate it it's ok for me.
>
> Should we also deprecate JavaImpl ?
>
> Regards
>
>
>
> On Thu, Mar 3, 2016 at 9:55 PM, <fs...@apache.org> wrote:
>
>> Author: fschumacher
>> Date: Thu Mar  3 20:55:33 2016
>> New Revision: 1733521
>>
>> URL: http://svn.apache.org/viewvc?rev=1733521&view=rev
>> Log:
>> HTTP Request : Make Method field editable so that additional methods
>> (Webdav) can be added easily
>>
>> Bugzilla Id: 59083
>>
>> Modified:
>>      jmeter/trunk/bin/jmeter.properties
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.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/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>      jmeter/trunk/xdocs/usermanual/component_reference.xml
>>
>> Modified: jmeter/trunk/bin/jmeter.properties
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/bin/jmeter.properties (original)
>> +++ jmeter/trunk/bin/jmeter.properties Thu Mar  3 20:55:33 2016
>> @@ -987,6 +987,9 @@ beanshell.server.file=../extras/startup.
>>   # default to false
>>   #httpsampler.embedded_resources_use_md5=false
>>
>> +# List of extra HTTP methods that should be available in select box
>>
>> +#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
>> +
>>   # The encoding to be used if none is provided (default ISO-8859-1)
>>   #sampleresult.default.encoding=ISO-8859-1
>>
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> Thu Mar  3 20:55:33 2016
>> @@ -627,7 +627,7 @@ public class UrlConfigGui extends JPanel
>>
>>           if (notConfigOnly){
>>               method = new
>> JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
>> -                    HTTPSamplerBase.getValidMethodsAsArray());
>> +                    HTTPSamplerBase.getValidMethodsAsArray(), true);
>>               method.addChangeListener(this);
>>           }
>>
>>
>> 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=1733521&r1=1733520&r2=1733521&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
>> Thu Mar  3 20:55:33 2016
>> @@ -487,13 +487,11 @@ public class HTTPHC4Impl extends HTTPHCA
>>       protected void handleMethod(String method, HTTPSampleResult result,
>>               HttpRequestBase httpRequest, HttpContext localContext) throws
>> IOException {
>>           // Handle the various methods
>> -        if (method.equals(HTTPConstants.POST)) {
>> +        if (httpRequest instanceof HttpPost) {
>>               String postBody = sendPostData((HttpPost)httpRequest);
>>               result.setQueryString(postBody);
>> -        } else if (method.equals(HTTPConstants.PUT) ||
>> method.equals(HTTPConstants.PATCH)
>> -                || HttpWebdav.isWebdavMethod(method)
>> -                || method.equals(HTTPConstants.DELETE)) {
>> -            String entityBody = sendEntityData((
>> HttpEntityEnclosingRequestBase)httpRequest);
>> +        } else if (httpRequest instanceof HttpEntityEnclosingRequestBase)
>> {
>> +            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=1733521&r1=1733520&r2=1733521&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
>> Thu Mar  3 20:55:33 2016
>> @@ -22,7 +22,10 @@ import java.net.HttpURLConnection;
>>   import java.net.URL;
>>   import java.nio.charset.Charset;
>>   import java.util.ArrayList;
>> +import java.util.Arrays;
>> +import java.util.HashSet;
>>   import java.util.List;
>> +import java.util.Set;
>>
>>   import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>   import org.apache.jmeter.samplers.SampleResult;
>> @@ -35,6 +38,12 @@ public class HTTPSampleResult extends Sa
>>
>>       private static final long serialVersionUID = 240L;
>>
>> +    /** Set of all HTTP methods, that have no body */
>> +    private static final Set<String> METHODS_WITHOUT_BODY = new HashSet<>(
>> +            Arrays.asList(HTTPConstants.GET, HTTPConstants.HEAD,
>> +                    HTTPConstants.OPTIONS, HTTPConstants.DELETE,
>> +                    HTTPConstants.TRACE));
>> +
>>       private String cookies = ""; // never null
>>
>>       private String method;
>> @@ -138,10 +147,7 @@ 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)
>> -                    || HttpWebdav.isWebdavMethod(method)
>> -                    || HTTPConstants.DELETE.equals(method)) {
>> +            if (!METHODS_WITHOUT_BODY.contains(method)) {
>>                   sb.append("\n"+method+" data:\n");
>>                   sb.append(queryString);
>>                   sb.append("\n");
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> Thu Mar  3 20:55:33 2016
>> @@ -226,29 +226,36 @@ public abstract class HTTPSamplerBase ex
>>       }
>>
>>       public static final String DEFAULT_METHOD = HTTPConstants.GET; //
>> $NON-NLS-1$
>> -    // Supported methods:
>> -    private static final String [] METHODS = {
>> -        DEFAULT_METHOD, // i.e. GET
>> -        HTTPConstants.POST,
>> -        HTTPConstants.HEAD,
>> -        HTTPConstants.PUT,
>> -        HTTPConstants.OPTIONS,
>> -        HTTPConstants.TRACE,
>> -        HTTPConstants.DELETE,
>> -        HTTPConstants.PATCH,
>> -        HTTPConstants.PROPFIND,
>> -        HTTPConstants.PROPPATCH,
>> -        HTTPConstants.MKCOL,
>> -        HTTPConstants.COPY,
>> -        HTTPConstants.MOVE,
>> -        HTTPConstants.LOCK,
>> -        HTTPConstants.UNLOCK,
>> -        HTTPConstants.REPORT,
>> -        HTTPConstants.MKCALENDAR,
>> -        HTTPConstants.SEARCH
>> -        };
>>
>> -    private static final List<String> METHODLIST =
>> Collections.unmodifiableList(Arrays.asList(METHODS));
>> +    private static final List<String> METHODLIST;
>> +    static {
>> +        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
>> +            DEFAULT_METHOD, // i.e. GET
>> +            HTTPConstants.POST,
>> +            HTTPConstants.HEAD,
>> +            HTTPConstants.PUT,
>> +            HTTPConstants.OPTIONS,
>> +            HTTPConstants.TRACE,
>> +            HTTPConstants.DELETE,
>> +            HTTPConstants.PATCH,
>> +            HTTPConstants.PROPFIND,
>> +            HTTPConstants.PROPPATCH,
>> +            HTTPConstants.MKCOL,
>> +            HTTPConstants.COPY,
>> +            HTTPConstants.MOVE,
>> +            HTTPConstants.LOCK,
>> +            HTTPConstants.UNLOCK,
>> +            HTTPConstants.REPORT,
>> +            HTTPConstants.MKCALENDAR,
>> +            HTTPConstants.SEARCH
>> +        ));
>> +        String userDefinedMethods = JMeterUtils.getPropDefault(
>> +                "httpsampler.user_defined_methods", "");
>> +        if (StringUtils.isNotBlank(userDefinedMethods)) {
>> +
>> defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
>> +        }
>> +        METHODLIST = Collections.unmodifiableList(defaultMethods);
>> +    }
>>
>>       // @see mergeFileProperties
>>       // Must be private, as the file list needs special handling
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> Thu Mar  3 20:55:33 2016
>> @@ -19,38 +19,25 @@
>>   package org.apache.jmeter.protocol.http.sampler;
>>
>>   import java.net.URI;
>> -import java.util.Arrays;
>> -import java.util.HashSet;
>> -import java.util.Set;
>>
>>   import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
>> -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>
>>   /**
>>    * WebDav request
>> + *
>>    * @since 2.12
>>    */
>>   public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
>> -    private static final Set<String> WEBDAV_METHODS =
>> -            new HashSet<>(Arrays.asList(
>> -                    HTTPConstants.PROPFIND,
>> -                    HTTPConstants.PROPPATCH,
>> -                    HTTPConstants.MKCOL,
>> -                    HTTPConstants.COPY,
>> -                    HTTPConstants.MOVE,
>> -                    HTTPConstants.LOCK,
>> -                    HTTPConstants.UNLOCK,
>> -                    HTTPConstants.REPORT,
>> -                    HTTPConstants.MKCALENDAR,
>> -                    HTTPConstants.SEARCH
>> -            ));
>> -
>> -    private String davMethod;
>> +
>> +    private final String davMethod;
>>
>>       /**
>>        *
>> -     * @param davMethod method to use (has to be a Webdav method as
>> identified by {@link #isWebdavMethod(String)})
>> -     * @param uri {@link URI} to use
>> +     * @param davMethod
>> +     *            method to use (has to be a Webdav method as identified
>> by
>> +     *            {@link #isWebdavMethod(String)})
>> +     * @param uri
>> +     *            {@link URI} to use
>>        */
>>       public HttpWebdav(final String davMethod, final URI uri) {
>>           super();
>> @@ -64,10 +51,13 @@ public final class HttpWebdav extends Ht
>>       }
>>
>>       /**
>> -     * @param method Http Method
>> +     * @param method
>> +     *            Http Method
>>        * @return <code>true</code> if method is a Webdav one
>>        */
>>       public static boolean isWebdavMethod(String method) {
>> -        return WEBDAV_METHODS.contains(method);
>> +        // A HTTP method can be a token as specified in
>> +        // https://tools.ietf.org/html/rfc7230#section-3.2.6
>> +        return method != null &&
>> method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
>>       }
>>   }
>>
>> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
>> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Mar  3
>> 20:55:33 2016
>> @@ -232,7 +232,10 @@ https.default.protocol=SSLv3
>>             <code>JAVA</code> implementation). With
>> <code>HttpClient4</code>, the following methods related to WebDav are
>>             also allowed: <code>COPY</code>, <code>LOCK</code>,
>> <code>MKCOL</code>, <code>MOVE</code>,
>>             <code>PROPFIND</code>, <code>PROPPATCH</code>,
>> <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
>> -          <code>SEARCH</code>.</property>
>> +          <code>SEARCH</code>.
>> +          <p>More methods can be pre-defined for the HttpClient4 by using
>> the JMeter property
>> +            <code>httpsampler.user_defined_methods</code>.</p>
>> +        </property>
>>           <property name="Content Encoding" required="No">
>>           Content encoding to be used (for <code>POST</code>,
>> <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
>>           This is the character encoding to be used, and is not related to
>> the Content-Encoding HTTP header.
>>
>>
>>
>


Re: svn commit: r1733521 - in /jmeter/trunk: bin/ src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/usermanual/

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
I left another note on the bugzilla.

I think we should maybe think more about the Addition/deletion of Methods,
particularly when a method is already used by other samplers and deleted.

I don't know if we can find a good solution in short terms, not all code
would need reverting, only the one that makes the JLabelChoice editable and
the HttpWebdav changes.
We can keep the test on implementation.

What do you think ?
Regards

On Thu, Mar 3, 2016 at 10:05 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi Felix,
> Sorry for not answering , didn't have time to look at it.
>
> Regarding this commit, what about HttpJavaImpl and HC3 ?
>
> Looking into code, it appears anyway Java does not handle Webdav, nor
> patch. I am also not sure about methods different from POST/GET/PUT.
>
> Do you think we should make select box depend on chosen implementation ?
> knowing it can be:
> - In HTTP Requrest : Easy to test
> - A property : Easy to test
> - HTTP Request Default : More difficult
>
> For HC3, as we deprecate it it's ok for me.
>
> Should we also deprecate JavaImpl ?
>
> Regards
>
>
>
> On Thu, Mar 3, 2016 at 9:55 PM, <fs...@apache.org> wrote:
>
>> Author: fschumacher
>> Date: Thu Mar  3 20:55:33 2016
>> New Revision: 1733521
>>
>> URL: http://svn.apache.org/viewvc?rev=1733521&view=rev
>> Log:
>> HTTP Request : Make Method field editable so that additional methods
>> (Webdav) can be added easily
>>
>> Bugzilla Id: 59083
>>
>> Modified:
>>     jmeter/trunk/bin/jmeter.properties
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.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/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>>     jmeter/trunk/xdocs/usermanual/component_reference.xml
>>
>> Modified: jmeter/trunk/bin/jmeter.properties
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/bin/jmeter.properties (original)
>> +++ jmeter/trunk/bin/jmeter.properties Thu Mar  3 20:55:33 2016
>> @@ -987,6 +987,9 @@ beanshell.server.file=../extras/startup.
>>  # default to false
>>  #httpsampler.embedded_resources_use_md5=false
>>
>> +# List of extra HTTP methods that should be available in select box
>>
>> +#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
>> +
>>  # The encoding to be used if none is provided (default ISO-8859-1)
>>  #sampleresult.default.encoding=ISO-8859-1
>>
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
>> Thu Mar  3 20:55:33 2016
>> @@ -627,7 +627,7 @@ public class UrlConfigGui extends JPanel
>>
>>          if (notConfigOnly){
>>              method = new
>> JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
>> -                    HTTPSamplerBase.getValidMethodsAsArray());
>> +                    HTTPSamplerBase.getValidMethodsAsArray(), true);
>>              method.addChangeListener(this);
>>          }
>>
>>
>> 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=1733521&r1=1733520&r2=1733521&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
>> Thu Mar  3 20:55:33 2016
>> @@ -487,13 +487,11 @@ public class HTTPHC4Impl extends HTTPHCA
>>      protected void handleMethod(String method, HTTPSampleResult result,
>>              HttpRequestBase httpRequest, HttpContext localContext)
>> throws IOException {
>>          // Handle the various methods
>> -        if (method.equals(HTTPConstants.POST)) {
>> +        if (httpRequest instanceof HttpPost) {
>>              String postBody = sendPostData((HttpPost)httpRequest);
>>              result.setQueryString(postBody);
>> -        } else if (method.equals(HTTPConstants.PUT) ||
>> method.equals(HTTPConstants.PATCH)
>> -                || HttpWebdav.isWebdavMethod(method)
>> -                || method.equals(HTTPConstants.DELETE)) {
>> -            String entityBody = sendEntityData((
>> HttpEntityEnclosingRequestBase)httpRequest);
>> +        } else if (httpRequest instanceof
>> HttpEntityEnclosingRequestBase) {
>> +            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=1733521&r1=1733520&r2=1733521&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
>> Thu Mar  3 20:55:33 2016
>> @@ -22,7 +22,10 @@ import java.net.HttpURLConnection;
>>  import java.net.URL;
>>  import java.nio.charset.Charset;
>>  import java.util.ArrayList;
>> +import java.util.Arrays;
>> +import java.util.HashSet;
>>  import java.util.List;
>> +import java.util.Set;
>>
>>  import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>  import org.apache.jmeter.samplers.SampleResult;
>> @@ -35,6 +38,12 @@ public class HTTPSampleResult extends Sa
>>
>>      private static final long serialVersionUID = 240L;
>>
>> +    /** Set of all HTTP methods, that have no body */
>> +    private static final Set<String> METHODS_WITHOUT_BODY = new
>> HashSet<>(
>> +            Arrays.asList(HTTPConstants.GET, HTTPConstants.HEAD,
>> +                    HTTPConstants.OPTIONS, HTTPConstants.DELETE,
>> +                    HTTPConstants.TRACE));
>> +
>>      private String cookies = ""; // never null
>>
>>      private String method;
>> @@ -138,10 +147,7 @@ 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)
>> -                    || HttpWebdav.isWebdavMethod(method)
>> -                    || HTTPConstants.DELETE.equals(method)) {
>> +            if (!METHODS_WITHOUT_BODY.contains(method)) {
>>                  sb.append("\n"+method+" data:\n");
>>                  sb.append(queryString);
>>                  sb.append("\n");
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>> Thu Mar  3 20:55:33 2016
>> @@ -226,29 +226,36 @@ public abstract class HTTPSamplerBase ex
>>      }
>>
>>      public static final String DEFAULT_METHOD = HTTPConstants.GET; //
>> $NON-NLS-1$
>> -    // Supported methods:
>> -    private static final String [] METHODS = {
>> -        DEFAULT_METHOD, // i.e. GET
>> -        HTTPConstants.POST,
>> -        HTTPConstants.HEAD,
>> -        HTTPConstants.PUT,
>> -        HTTPConstants.OPTIONS,
>> -        HTTPConstants.TRACE,
>> -        HTTPConstants.DELETE,
>> -        HTTPConstants.PATCH,
>> -        HTTPConstants.PROPFIND,
>> -        HTTPConstants.PROPPATCH,
>> -        HTTPConstants.MKCOL,
>> -        HTTPConstants.COPY,
>> -        HTTPConstants.MOVE,
>> -        HTTPConstants.LOCK,
>> -        HTTPConstants.UNLOCK,
>> -        HTTPConstants.REPORT,
>> -        HTTPConstants.MKCALENDAR,
>> -        HTTPConstants.SEARCH
>> -        };
>>
>> -    private static final List<String> METHODLIST =
>> Collections.unmodifiableList(Arrays.asList(METHODS));
>> +    private static final List<String> METHODLIST;
>> +    static {
>> +        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
>> +            DEFAULT_METHOD, // i.e. GET
>> +            HTTPConstants.POST,
>> +            HTTPConstants.HEAD,
>> +            HTTPConstants.PUT,
>> +            HTTPConstants.OPTIONS,
>> +            HTTPConstants.TRACE,
>> +            HTTPConstants.DELETE,
>> +            HTTPConstants.PATCH,
>> +            HTTPConstants.PROPFIND,
>> +            HTTPConstants.PROPPATCH,
>> +            HTTPConstants.MKCOL,
>> +            HTTPConstants.COPY,
>> +            HTTPConstants.MOVE,
>> +            HTTPConstants.LOCK,
>> +            HTTPConstants.UNLOCK,
>> +            HTTPConstants.REPORT,
>> +            HTTPConstants.MKCALENDAR,
>> +            HTTPConstants.SEARCH
>> +        ));
>> +        String userDefinedMethods = JMeterUtils.getPropDefault(
>> +                "httpsampler.user_defined_methods", "");
>> +        if (StringUtils.isNotBlank(userDefinedMethods)) {
>> +
>> defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
>> +        }
>> +        METHODLIST = Collections.unmodifiableList(defaultMethods);
>> +    }
>>
>>      // @see mergeFileProperties
>>      // Must be private, as the file list needs special handling
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>> Thu Mar  3 20:55:33 2016
>> @@ -19,38 +19,25 @@
>>  package org.apache.jmeter.protocol.http.sampler;
>>
>>  import java.net.URI;
>> -import java.util.Arrays;
>> -import java.util.HashSet;
>> -import java.util.Set;
>>
>>  import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
>> -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>>
>>  /**
>>   * WebDav request
>> + *
>>   * @since 2.12
>>   */
>>  public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
>> -    private static final Set<String> WEBDAV_METHODS =
>> -            new HashSet<>(Arrays.asList(
>> -                    HTTPConstants.PROPFIND,
>> -                    HTTPConstants.PROPPATCH,
>> -                    HTTPConstants.MKCOL,
>> -                    HTTPConstants.COPY,
>> -                    HTTPConstants.MOVE,
>> -                    HTTPConstants.LOCK,
>> -                    HTTPConstants.UNLOCK,
>> -                    HTTPConstants.REPORT,
>> -                    HTTPConstants.MKCALENDAR,
>> -                    HTTPConstants.SEARCH
>> -            ));
>> -
>> -    private String davMethod;
>> +
>> +    private final String davMethod;
>>
>>      /**
>>       *
>> -     * @param davMethod method to use (has to be a Webdav method as
>> identified by {@link #isWebdavMethod(String)})
>> -     * @param uri {@link URI} to use
>> +     * @param davMethod
>> +     *            method to use (has to be a Webdav method as identified
>> by
>> +     *            {@link #isWebdavMethod(String)})
>> +     * @param uri
>> +     *            {@link URI} to use
>>       */
>>      public HttpWebdav(final String davMethod, final URI uri) {
>>          super();
>> @@ -64,10 +51,13 @@ public final class HttpWebdav extends Ht
>>      }
>>
>>      /**
>> -     * @param method Http Method
>> +     * @param method
>> +     *            Http Method
>>       * @return <code>true</code> if method is a Webdav one
>>       */
>>      public static boolean isWebdavMethod(String method) {
>> -        return WEBDAV_METHODS.contains(method);
>> +        // A HTTP method can be a token as specified in
>> +        // https://tools.ietf.org/html/rfc7230#section-3.2.6
>> +        return method != null &&
>> method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
>>      }
>>  }
>>
>> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733521&r1=1733520&r2=1733521&view=diff
>>
>> ==============================================================================
>> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
>> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Mar  3
>> 20:55:33 2016
>> @@ -232,7 +232,10 @@ https.default.protocol=SSLv3
>>            <code>JAVA</code> implementation). With
>> <code>HttpClient4</code>, the following methods related to WebDav are
>>            also allowed: <code>COPY</code>, <code>LOCK</code>,
>> <code>MKCOL</code>, <code>MOVE</code>,
>>            <code>PROPFIND</code>, <code>PROPPATCH</code>,
>> <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
>> -          <code>SEARCH</code>.</property>
>> +          <code>SEARCH</code>.
>> +          <p>More methods can be pre-defined for the HttpClient4 by
>> using the JMeter property
>> +            <code>httpsampler.user_defined_methods</code>.</p>
>> +        </property>
>>          <property name="Content Encoding" required="No">
>>          Content encoding to be used (for <code>POST</code>,
>> <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
>>          This is the character encoding to be used, and is not related to
>> the Content-Encoding HTTP header.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1733521 - in /jmeter/trunk: bin/ src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/usermanual/

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Felix,
Sorry for not answering , didn't have time to look at it.

Regarding this commit, what about HttpJavaImpl and HC3 ?

Looking into code, it appears anyway Java does not handle Webdav, nor
patch. I am also not sure about methods different from POST/GET/PUT.

Do you think we should make select box depend on chosen implementation ?
knowing it can be:
- In HTTP Requrest : Easy to test
- A property : Easy to test
- HTTP Request Default : More difficult

For HC3, as we deprecate it it's ok for me.

Should we also deprecate JavaImpl ?

Regards



On Thu, Mar 3, 2016 at 9:55 PM, <fs...@apache.org> wrote:

> Author: fschumacher
> Date: Thu Mar  3 20:55:33 2016
> New Revision: 1733521
>
> URL: http://svn.apache.org/viewvc?rev=1733521&view=rev
> Log:
> HTTP Request : Make Method field editable so that additional methods
> (Webdav) can be added easily
>
> Bugzilla Id: 59083
>
> Modified:
>     jmeter/trunk/bin/jmeter.properties
>
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.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/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
>
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
>     jmeter/trunk/xdocs/usermanual/component_reference.xml
>
> Modified: jmeter/trunk/bin/jmeter.properties
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1733521&r1=1733520&r2=1733521&view=diff
>
> ==============================================================================
> --- jmeter/trunk/bin/jmeter.properties (original)
> +++ jmeter/trunk/bin/jmeter.properties Thu Mar  3 20:55:33 2016
> @@ -987,6 +987,9 @@ beanshell.server.file=../extras/startup.
>  # default to false
>  #httpsampler.embedded_resources_use_md5=false
>
> +# List of extra HTTP methods that should be available in select box
>
> +#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
> +
>  # The encoding to be used if none is provided (default ISO-8859-1)
>  #sampleresult.default.encoding=ISO-8859-1
>
>
> Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>
> ==============================================================================
> ---
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
> (original)
> +++
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
> Thu Mar  3 20:55:33 2016
> @@ -627,7 +627,7 @@ public class UrlConfigGui extends JPanel
>
>          if (notConfigOnly){
>              method = new
> JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
> -                    HTTPSamplerBase.getValidMethodsAsArray());
> +                    HTTPSamplerBase.getValidMethodsAsArray(), true);
>              method.addChangeListener(this);
>          }
>
>
> 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=1733521&r1=1733520&r2=1733521&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
> Thu Mar  3 20:55:33 2016
> @@ -487,13 +487,11 @@ public class HTTPHC4Impl extends HTTPHCA
>      protected void handleMethod(String method, HTTPSampleResult result,
>              HttpRequestBase httpRequest, HttpContext localContext) throws
> IOException {
>          // Handle the various methods
> -        if (method.equals(HTTPConstants.POST)) {
> +        if (httpRequest instanceof HttpPost) {
>              String postBody = sendPostData((HttpPost)httpRequest);
>              result.setQueryString(postBody);
> -        } else if (method.equals(HTTPConstants.PUT) ||
> method.equals(HTTPConstants.PATCH)
> -                || HttpWebdav.isWebdavMethod(method)
> -                || method.equals(HTTPConstants.DELETE)) {
> -            String entityBody = sendEntityData((
> HttpEntityEnclosingRequestBase)httpRequest);
> +        } else if (httpRequest instanceof HttpEntityEnclosingRequestBase)
> {
> +            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=1733521&r1=1733520&r2=1733521&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
> Thu Mar  3 20:55:33 2016
> @@ -22,7 +22,10 @@ import java.net.HttpURLConnection;
>  import java.net.URL;
>  import java.nio.charset.Charset;
>  import java.util.ArrayList;
> +import java.util.Arrays;
> +import java.util.HashSet;
>  import java.util.List;
> +import java.util.Set;
>
>  import org.apache.jmeter.protocol.http.util.HTTPConstants;
>  import org.apache.jmeter.samplers.SampleResult;
> @@ -35,6 +38,12 @@ public class HTTPSampleResult extends Sa
>
>      private static final long serialVersionUID = 240L;
>
> +    /** Set of all HTTP methods, that have no body */
> +    private static final Set<String> METHODS_WITHOUT_BODY = new HashSet<>(
> +            Arrays.asList(HTTPConstants.GET, HTTPConstants.HEAD,
> +                    HTTPConstants.OPTIONS, HTTPConstants.DELETE,
> +                    HTTPConstants.TRACE));
> +
>      private String cookies = ""; // never null
>
>      private String method;
> @@ -138,10 +147,7 @@ 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)
> -                    || HttpWebdav.isWebdavMethod(method)
> -                    || HTTPConstants.DELETE.equals(method)) {
> +            if (!METHODS_WITHOUT_BODY.contains(method)) {
>                  sb.append("\n"+method+" data:\n");
>                  sb.append(queryString);
>                  sb.append("\n");
>
> Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>
> ==============================================================================
> ---
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
> (original)
> +++
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
> Thu Mar  3 20:55:33 2016
> @@ -226,29 +226,36 @@ public abstract class HTTPSamplerBase ex
>      }
>
>      public static final String DEFAULT_METHOD = HTTPConstants.GET; //
> $NON-NLS-1$
> -    // Supported methods:
> -    private static final String [] METHODS = {
> -        DEFAULT_METHOD, // i.e. GET
> -        HTTPConstants.POST,
> -        HTTPConstants.HEAD,
> -        HTTPConstants.PUT,
> -        HTTPConstants.OPTIONS,
> -        HTTPConstants.TRACE,
> -        HTTPConstants.DELETE,
> -        HTTPConstants.PATCH,
> -        HTTPConstants.PROPFIND,
> -        HTTPConstants.PROPPATCH,
> -        HTTPConstants.MKCOL,
> -        HTTPConstants.COPY,
> -        HTTPConstants.MOVE,
> -        HTTPConstants.LOCK,
> -        HTTPConstants.UNLOCK,
> -        HTTPConstants.REPORT,
> -        HTTPConstants.MKCALENDAR,
> -        HTTPConstants.SEARCH
> -        };
>
> -    private static final List<String> METHODLIST =
> Collections.unmodifiableList(Arrays.asList(METHODS));
> +    private static final List<String> METHODLIST;
> +    static {
> +        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
> +            DEFAULT_METHOD, // i.e. GET
> +            HTTPConstants.POST,
> +            HTTPConstants.HEAD,
> +            HTTPConstants.PUT,
> +            HTTPConstants.OPTIONS,
> +            HTTPConstants.TRACE,
> +            HTTPConstants.DELETE,
> +            HTTPConstants.PATCH,
> +            HTTPConstants.PROPFIND,
> +            HTTPConstants.PROPPATCH,
> +            HTTPConstants.MKCOL,
> +            HTTPConstants.COPY,
> +            HTTPConstants.MOVE,
> +            HTTPConstants.LOCK,
> +            HTTPConstants.UNLOCK,
> +            HTTPConstants.REPORT,
> +            HTTPConstants.MKCALENDAR,
> +            HTTPConstants.SEARCH
> +        ));
> +        String userDefinedMethods = JMeterUtils.getPropDefault(
> +                "httpsampler.user_defined_methods", "");
> +        if (StringUtils.isNotBlank(userDefinedMethods)) {
> +
> defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
> +        }
> +        METHODLIST = Collections.unmodifiableList(defaultMethods);
> +    }
>
>      // @see mergeFileProperties
>      // Must be private, as the file list needs special handling
>
> Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java?rev=1733521&r1=1733520&r2=1733521&view=diff
>
> ==============================================================================
> ---
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
> (original)
> +++
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java
> Thu Mar  3 20:55:33 2016
> @@ -19,38 +19,25 @@
>  package org.apache.jmeter.protocol.http.sampler;
>
>  import java.net.URI;
> -import java.util.Arrays;
> -import java.util.HashSet;
> -import java.util.Set;
>
>  import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
> -import org.apache.jmeter.protocol.http.util.HTTPConstants;
>
>  /**
>   * WebDav request
> + *
>   * @since 2.12
>   */
>  public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
> -    private static final Set<String> WEBDAV_METHODS =
> -            new HashSet<>(Arrays.asList(
> -                    HTTPConstants.PROPFIND,
> -                    HTTPConstants.PROPPATCH,
> -                    HTTPConstants.MKCOL,
> -                    HTTPConstants.COPY,
> -                    HTTPConstants.MOVE,
> -                    HTTPConstants.LOCK,
> -                    HTTPConstants.UNLOCK,
> -                    HTTPConstants.REPORT,
> -                    HTTPConstants.MKCALENDAR,
> -                    HTTPConstants.SEARCH
> -            ));
> -
> -    private String davMethod;
> +
> +    private final String davMethod;
>
>      /**
>       *
> -     * @param davMethod method to use (has to be a Webdav method as
> identified by {@link #isWebdavMethod(String)})
> -     * @param uri {@link URI} to use
> +     * @param davMethod
> +     *            method to use (has to be a Webdav method as identified
> by
> +     *            {@link #isWebdavMethod(String)})
> +     * @param uri
> +     *            {@link URI} to use
>       */
>      public HttpWebdav(final String davMethod, final URI uri) {
>          super();
> @@ -64,10 +51,13 @@ public final class HttpWebdav extends Ht
>      }
>
>      /**
> -     * @param method Http Method
> +     * @param method
> +     *            Http Method
>       * @return <code>true</code> if method is a Webdav one
>       */
>      public static boolean isWebdavMethod(String method) {
> -        return WEBDAV_METHODS.contains(method);
> +        // A HTTP method can be a token as specified in
> +        // https://tools.ietf.org/html/rfc7230#section-3.2.6
> +        return method != null &&
> method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
>      }
>  }
>
> Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733521&r1=1733520&r2=1733521&view=diff
>
> ==============================================================================
> --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
> +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Thu Mar  3
> 20:55:33 2016
> @@ -232,7 +232,10 @@ https.default.protocol=SSLv3
>            <code>JAVA</code> implementation). With
> <code>HttpClient4</code>, the following methods related to WebDav are
>            also allowed: <code>COPY</code>, <code>LOCK</code>,
> <code>MKCOL</code>, <code>MOVE</code>,
>            <code>PROPFIND</code>, <code>PROPPATCH</code>,
> <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
> -          <code>SEARCH</code>.</property>
> +          <code>SEARCH</code>.
> +          <p>More methods can be pre-defined for the HttpClient4 by using
> the JMeter property
> +            <code>httpsampler.user_defined_methods</code>.</p>
> +        </property>
>          <property name="Content Encoding" required="No">
>          Content encoding to be used (for <code>POST</code>,
> <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
>          This is the character encoding to be used, and is not related to
> the Content-Encoding HTTP header.
>
>
>


-- 
Cordialement.
Philippe Mouawad.