Add HTTP QUERY method to the HTTP Request method list (#6854)

Offer QUERY in the HTTP Request method list. Sending QUERY already worked with
HttpClient4 and HttpClient5; the Java implementation does not support it.

Fixes #6743

Generated-by: Claude Code 2.1.330 (Claude Opus 5.5) (indentation fix only)
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
index 43b446e..eb9cced 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
@@ -254,7 +254,8 @@
             HTTPConstants.UNLOCK,
             HTTPConstants.REPORT,
             HTTPConstants.MKCALENDAR,
-            HTTPConstants.SEARCH
+            HTTPConstants.SEARCH,
+            HTTPConstants.QUERY
         ));
         String userDefinedMethods = JMeterUtils.getPropDefault(
                 "httpsampler.user_defined_methods", "");
diff --git a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java
index 5defe6a..061a108 100644
--- a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java
+++ b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java
@@ -67,6 +67,7 @@
     String REPORT = "REPORT"; // $NON-NLS-1$
     String MKCALENDAR = "MKCALENDAR"; // $NON-NLS-1$
     String SEARCH = "SEARCH"; // $NON-NLS-1$
+    String QUERY = "QUERY"; // $NON-NLS-1$
     String HEADER_AUTHORIZATION = "Authorization"; // $NON-NLS-1$
     String HEADER_COOKIE = "Cookie"; // $NON-NLS-1$
     String HEADER_COOKIE_IN_REQUEST = "Cookie:"; // $NON-NLS-1$
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpQuery.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpQuery.java
new file mode 100644
index 0000000..c2d5f78
--- /dev/null
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHttpQuery.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.protocol.http.sampler;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.request;
+import static com.github.tomakehurst.wiremock.client.WireMock.requestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.protocol.http.util.HTTPConstants;
+import org.apache.jmeter.samplers.SampleResult;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
+import com.github.tomakehurst.wiremock.junit5.WireMockTest;
+
+@WireMockTest
+class TestHttpQuery extends JMeterTestCase {
+
+    private static HTTPSamplerProxy querySampler(String impl, WireMockRuntimeInfo server) {
+        HTTPSamplerProxy sampler = new HTTPSamplerProxy(impl);
+        sampler.setProtocol("http");
+        sampler.setDomain("localhost");
+        sampler.setPort(server.getHttpPort());
+        sampler.setPath("/search");
+        sampler.setMethod(HTTPConstants.QUERY);
+        sampler.setConnectTimeout("5000");
+        sampler.setResponseTimeout("5000");
+        return sampler;
+    }
+
+    @Test
+    void queryIsOfferedInMethodList() {
+        assertTrue(Arrays.asList(HTTPSamplerBase.getValidMethodsAsArray()).contains(HTTPConstants.QUERY));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {HTTPSamplerFactory.IMPL_HTTP_CLIENT4, HTTPSamplerFactory.IMPL_HTTP_CLIENT5})
+    void querySendsRawBody(String impl, WireMockRuntimeInfo server) {
+        server.getWireMock().register(request("QUERY", urlEqualTo("/search"))
+                .willReturn(aResponse().withStatus(200).withBody("OK")));
+        HTTPSamplerProxy sampler = querySampler(impl, server);
+        sampler.setPostBodyRaw(true);
+        sampler.addNonEncodedArgument("", "{\"q\":\"jmeter\"}", "");
+        SampleResult res = sampler.sample();
+        assertTrue(res.isSuccessful(), res.getResponseMessage());
+        server.getWireMock().verifyThat(1, requestedFor("QUERY", urlEqualTo("/search"))
+                .withRequestBody(equalTo("{\"q\":\"jmeter\"}")));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {HTTPSamplerFactory.IMPL_HTTP_CLIENT4, HTTPSamplerFactory.IMPL_HTTP_CLIENT5})
+    void querySendsFormParameters(String impl, WireMockRuntimeInfo server) {
+        server.getWireMock().register(request("QUERY", urlEqualTo("/search"))
+                .willReturn(aResponse().withStatus(200)));
+        HTTPSamplerProxy sampler = querySampler(impl, server);
+        sampler.addArgument("a", "1");
+        sampler.addArgument("b", "x y");
+        SampleResult res = sampler.sample();
+        assertTrue(res.isSuccessful(), res.getResponseMessage());
+        server.getWireMock().verifyThat(1, requestedFor("QUERY", urlEqualTo("/search"))
+                .withRequestBody(equalTo("a=1&b=x+y")));
+    }
+
+    @Test
+    void javaImplementationRejectsQuery(WireMockRuntimeInfo server) {
+        SampleResult res = querySampler(HTTPSamplerFactory.IMPL_JAVA, server).sample();
+        assertFalse(res.isSuccessful());
+    }
+}
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index e2350f7..cb70f8a 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -99,6 +99,8 @@
     <li><pr>6742</pr>Add the <code>HTTP Version</code> combo box (property <code>HTTPSampler.httpVersion</code>) to the HTTP Request sampler and the HTTP Request Defaults, so the HTTP version can be selected per sampler instead of only globally with the <code>httpclient.version</code> property. An empty value keeps using that property, which now defaults to <code>HTTP/1.1</code>.</li>
     <li><pr>6742</pr>Send a <code>Host</code> header of the HTTP Header Manager without its port when that port is the default one of the URL in the <code>HttpClient5</code> sampler implementation, as the <code>HttpClient4</code> implementation does.</li>
     <li><pr>6742</pr>Follow automatic redirects to another host in the <code>HttpClient5</code> sampler implementation, like the <code>HttpClient4</code> implementation does, instead of returning the redirect when the request carries cookies or credentials. Each redirect is sent with the cookies of the HTTP Cookie Manager and the credentials of the HTTP Authorization Manager for its own URL, the cookies the redirects set are kept in the Cookie Manager, and a <code>Cookie</code> or <code>Authorization</code> header of the HTTP Header Manager is only sent to the host of the initial URL. The number of redirects is limited by <code>httpsampler.max_redirects</code>, and cookies are only handled by the Cookie Manager, so none are sent without one.</li>
+    <li><issue>6743</issue><pr>6854</pr>Add <code>QUERY</code> to the list of HTTP Request methods. If <code>httpsampler.user_defined_methods</code> already contains
+      <code>QUERY</code>, it will appear twice in the method list.</li>
   </ul>
 
   <p>HTTP/2 support for the HttpClient5 sampler implementation:</p>
diff --git a/xdocs/usermanual/component_reference.xml b/xdocs/usermanual/component_reference.xml
index 2e64ec3..7bbce38 100644
--- a/xdocs/usermanual/component_reference.xml
+++ b/xdocs/usermanual/component_reference.xml
@@ -272,7 +272,8 @@
           <code>JAVA</code> implementation). With <code>HttpClient4</code> or <code>HttpClient5</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>.
+          <code>SEARCH</code>. The <code>QUERY</code> method (safe and idempotent request with a body) is also
+          available with <code>HttpClient4</code> or <code>HttpClient5</code>; it is not supported by the <code>JAVA</code> implementation.
           <p>More methods can be pre-defined for the HttpClient4 by using the JMeter property
             <code>httpsampler.user_defined_methods</code>.</p>
         </property>