View | Details | Raw Unified | Return to bug 59083
Collapse All | Expand All

(-)a/bin/jmeter.properties (+3 lines)
Lines 999-1004 beanshell.server.file=../extras/startup.bsh Link Here
999
# default to false
999
# default to false
1000
#httpsampler.embedded_resources_use_md5=false
1000
#httpsampler.embedded_resources_use_md5=false
1001
1001
1002
# List of extra HTTP methods that should be available
1003
#httpsampler.user_defined_methods=VERSION-CONTROL,REPORT,CHECKOUT,CHECKIN,UNCHECKOUT,MKWORKSPACE,UPDATE,LABEL,MERGE,BASELINE-CONTROL,MKACTIVITY
1004
1002
# The encoding to be used if none is provided (default ISO-8859-1)
1005
# The encoding to be used if none is provided (default ISO-8859-1)
1003
#sampleresult.default.encoding=ISO-8859-1
1006
#sampleresult.default.encoding=ISO-8859-1
1004
1007
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java (-1 / +1 lines)
Lines 627-633 public class UrlConfigGui extends JPanel implements ChangeListener { Link Here
627
627
628
        if (notConfigOnly){
628
        if (notConfigOnly){
629
            method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
629
            method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
630
                    HTTPSamplerBase.getValidMethodsAsArray());
630
                    HTTPSamplerBase.getValidMethodsAsArray(), true);
631
            method.addChangeListener(this);
631
            method.addChangeListener(this);
632
        }
632
        }
633
633
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (-4 / +5 lines)
Lines 490-499 public class HTTPHC4Impl extends HTTPHCAbstractImpl { Link Here
490
        if (method.equals(HTTPConstants.POST)) {
490
        if (method.equals(HTTPConstants.POST)) {
491
            String postBody = sendPostData((HttpPost)httpRequest);
491
            String postBody = sendPostData((HttpPost)httpRequest);
492
            result.setQueryString(postBody);
492
            result.setQueryString(postBody);
493
        } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)
493
        } else if (method.equals(HTTPConstants.PUT)
494
                || HttpWebdav.isWebdavMethod(method)
494
                || method.equals(HTTPConstants.PATCH)
495
                || method.equals(HTTPConstants.DELETE)) {
495
                || method.equals(HTTPConstants.DELETE)
496
            String entityBody = sendEntityData(( HttpEntityEnclosingRequestBase)httpRequest);
496
                || HttpWebdav.isWebdavMethod(method)) {
497
            String entityBody = sendEntityData((HttpEntityEnclosingRequestBase) httpRequest);
497
            result.setQueryString(entityBody);
498
            result.setQueryString(entityBody);
498
        }
499
        }
499
    }
500
    }
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (-23 / +30 lines)
Lines 226-254 public abstract class HTTPSamplerBase extends AbstractSampler Link Here
226
    }
226
    }
227
227
228
    public static final String DEFAULT_METHOD = HTTPConstants.GET; // $NON-NLS-1$
228
    public static final String DEFAULT_METHOD = HTTPConstants.GET; // $NON-NLS-1$
229
    // Supported methods:
229
230
    private static final String [] METHODS = {
230
    private static final List<String> METHODLIST;
231
        DEFAULT_METHOD, // i.e. GET
231
    static {
232
        HTTPConstants.POST,
232
        List<String> defaultMethods = new ArrayList<>(Arrays.asList(
233
        HTTPConstants.HEAD,
233
            DEFAULT_METHOD, // i.e. GET
234
        HTTPConstants.PUT,
234
            HTTPConstants.POST,
235
        HTTPConstants.OPTIONS,
235
            HTTPConstants.HEAD,
236
        HTTPConstants.TRACE,
236
            HTTPConstants.PUT,
237
        HTTPConstants.DELETE,
237
            HTTPConstants.OPTIONS,
238
        HTTPConstants.PATCH,
238
            HTTPConstants.TRACE,
239
        HTTPConstants.PROPFIND,
239
            HTTPConstants.DELETE,
240
        HTTPConstants.PROPPATCH,
240
            HTTPConstants.PATCH,
241
        HTTPConstants.MKCOL,
241
            HTTPConstants.PROPFIND,
242
        HTTPConstants.COPY,
242
            HTTPConstants.PROPPATCH,
243
        HTTPConstants.MOVE,
243
            HTTPConstants.MKCOL,
244
        HTTPConstants.LOCK,
244
            HTTPConstants.COPY,
245
        HTTPConstants.UNLOCK,
245
            HTTPConstants.MOVE,
246
        HTTPConstants.REPORT,
246
            HTTPConstants.LOCK,
247
        HTTPConstants.MKCALENDAR,
247
            HTTPConstants.UNLOCK,
248
        HTTPConstants.SEARCH
248
            HTTPConstants.REPORT,
249
        };
249
            HTTPConstants.MKCALENDAR,
250
250
            HTTPConstants.SEARCH
251
    private static final List<String> METHODLIST = Collections.unmodifiableList(Arrays.asList(METHODS));
251
        ));
252
        String userDefinedMethods = JMeterUtils.getPropDefault(
253
                "httpsampler.user_defined_methods", "");
254
        if (StringUtils.isNotBlank(userDefinedMethods)) {
255
            defaultMethods.addAll(Arrays.asList(userDefinedMethods.split("\\s*,\\s*")));
256
        }
257
        METHODLIST = Collections.unmodifiableList(defaultMethods);
258
    }
252
259
253
    // @see mergeFileProperties
260
    // @see mergeFileProperties
254
    // Must be private, as the file list needs special handling
261
    // Must be private, as the file list needs special handling
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HttpWebdav.java (-23 / +13 lines)
Lines 19-56 Link Here
19
package org.apache.jmeter.protocol.http.sampler;
19
package org.apache.jmeter.protocol.http.sampler;
20
20
21
import java.net.URI;
21
import java.net.URI;
22
import java.util.Arrays;
23
import java.util.HashSet;
24
import java.util.Set;
25
22
26
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
23
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
27
import org.apache.jmeter.protocol.http.util.HTTPConstants;
28
24
29
/**
25
/**
30
 * WebDav request
26
 * WebDav request
27
 *
31
 * @since 2.12
28
 * @since 2.12
32
 */
29
 */
33
public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
30
public final class HttpWebdav extends HttpEntityEnclosingRequestBase {
34
    private static final Set<String> WEBDAV_METHODS =
31
35
            new HashSet<>(Arrays.asList(
32
    private final String davMethod;
36
                    HTTPConstants.PROPFIND,
37
                    HTTPConstants.PROPPATCH,
38
                    HTTPConstants.MKCOL,
39
                    HTTPConstants.COPY,
40
                    HTTPConstants.MOVE,
41
                    HTTPConstants.LOCK,
42
                    HTTPConstants.UNLOCK,
43
                    HTTPConstants.REPORT,
44
                    HTTPConstants.MKCALENDAR,
45
                    HTTPConstants.SEARCH
46
            ));
47
    
48
    private String davMethod;
49
33
50
    /**
34
    /**
51
     * 
35
     * 
52
     * @param davMethod method to use (has to be a Webdav method as identified by {@link #isWebdavMethod(String)})
36
     * @param davMethod
53
     * @param uri {@link URI} to use
37
     *            method to use (has to be a Webdav method as identified by
38
     *            {@link #isWebdavMethod(String)})
39
     * @param uri
40
     *            {@link URI} to use
54
     */
41
     */
55
    public HttpWebdav(final String davMethod, final URI uri) {
42
    public HttpWebdav(final String davMethod, final URI uri) {
56
        super();
43
        super();
Lines 64-73 public final class HttpWebdav extends HttpEntityEnclosingRequestBase { Link Here
64
    }
51
    }
65
52
66
    /**
53
    /**
67
     * @param method Http Method
54
     * @param method
55
     *            Http Method
68
     * @return <code>true</code> if method is a Webdav one
56
     * @return <code>true</code> if method is a Webdav one
69
     */
57
     */
70
    public static boolean isWebdavMethod(String method) {
58
    public static boolean isWebdavMethod(String method) {
71
        return WEBDAV_METHODS.contains(method);
59
        // A HTTP method can be a token as specified in
60
        // https://tools.ietf.org/html/rfc7230#section-3.2.6
61
        return method != null && method.matches("^(?i)[\\da-z!#$%&'*+\\-.^_`|~]+$");
72
    }
62
    }
73
}
63
}
(-)a/test/src/org/apache/jmeter/protocol/http/sampler/TestHttpWebdav.java (+63 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.protocol.http.sampler;
20
21
import static org.junit.Assert.assertEquals;
22
import static org.junit.Assert.assertFalse;
23
import static org.junit.Assert.assertTrue;
24
25
import java.net.URI;
26
import java.net.URISyntaxException;
27
import java.util.Arrays;
28
import java.util.List;
29
30
import org.apache.http.client.methods.HttpRequestBase;
31
import org.apache.jmeter.protocol.http.util.HTTPConstants;
32
import org.junit.Test;
33
34
public class TestHttpWebdav {
35
36
    private static final List<String> VALID_METHODS = Arrays.asList("foo",
37
            "BAR", "123", "VERSION-CONTROL", HTTPConstants.PROPFIND);
38
39
    private static final List<String> INVALID_METHODS = Arrays.asList("", null,
40
            "bär", "with blank", "\"", "Foo(bar)", ":thing", "<xml>");
41
42
    @Test
43
    public void testisWebdavMethod() {
44
        for (String method : VALID_METHODS) {
45
            assertTrue(method + " is a HttpWebdav method",
46
                    HttpWebdav.isWebdavMethod(method));
47
        }
48
        for (String method : INVALID_METHODS) {
49
            assertFalse(method + " is not a HttpWebdav method",
50
                    HttpWebdav.isWebdavMethod(method));
51
        }
52
    }
53
54
    @Test
55
    public void testGetMethod() throws URISyntaxException {
56
        for (String method : VALID_METHODS) {
57
            HttpRequestBase request = new HttpWebdav(method, new URI(
58
                    "http://example.com"));
59
            assertEquals(method, request.getMethod());
60
        }
61
    }
62
63
}
(-)a/xdocs/usermanual/component_reference.xml (-2 / +4 lines)
Lines 234-240 https.default.protocol=SSLv3 Link Here
234
          <code>JAVA</code> implementation). With <code>HttpClient4</code>, the following methods related to WebDav are
234
          <code>JAVA</code> implementation). With <code>HttpClient4</code>, the following methods related to WebDav are
235
          also allowed: <code>COPY</code>, <code>LOCK</code>, <code>MKCOL</code>, <code>MOVE</code>,
235
          also allowed: <code>COPY</code>, <code>LOCK</code>, <code>MKCOL</code>, <code>MOVE</code>,
236
          <code>PROPFIND</code>, <code>PROPPATCH</code>, <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
236
          <code>PROPFIND</code>, <code>PROPPATCH</code>, <code>UNLOCK</code>, <code>REPORT</code>, <code>MKCALENDAR</code>,
237
          <code>SEARCH</code>.</property>
237
          <code>SEARCH</code>.
238
          <p>More methods can be pre-defined for the HttpClient4 by using the JMeter property
239
            <code>httpsampler.user_defined_methods</code>.</p>
240
        </property>
238
        <property name="Content Encoding" required="No">
241
        <property name="Content Encoding" required="No">
239
        Content encoding to be used (for <code>POST</code>, <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
242
        Content encoding to be used (for <code>POST</code>, <code>PUT</code>, <code>PATCH</code> and <code>FILE</code>).
240
        This is the character encoding to be used, and is not related to the Content-Encoding HTTP header.
243
        This is the character encoding to be used, and is not related to the Content-Encoding HTTP header.
241
- 

Return to bug 59083