From a4bb78f9a9f6e14f410204f6b4dccd25dabe4f01 Mon Sep 17 00:00:00 2001 From: AdzerKI Date: Sun, 22 Nov 2026 08:33:43 +0300 Subject: [PATCH] Support extension methods in HttpComponentsClientHttpRequestFactory HttpMethod.valueOf() accepts any method name, and the JDK, Jetty and Reactor request factories send it as is, but HttpComponentsClientHttpRequestFactory throws an IllegalArgumentException for anything other than the standard methods, so a RestClient on Apache HttpClient cannot send PROPFIND or REPORT to a WebDAV or CalDAV server. It now creates an HttpUriRequestBase with the method name, as it already did for QUERY. Signed-off-by: AdzerKI --- .../http/client/HttpComponentsClientHttpRequestFactory.java | 5 +---- .../client/HttpComponentsClientHttpRequestFactoryTests.java | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java index cd8cc1988c2..b98810c8eb2 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java @@ -299,10 +299,7 @@ else if (HttpMethod.OPTIONS.equals(httpMethod)) { else if (HttpMethod.TRACE.equals(httpMethod)) { return new HttpTrace(uri); } - else if (HttpMethod.QUERY.equals(httpMethod)) { - return new HttpUriRequestBase(HttpMethod.QUERY.name(), uri); - } - throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod); + return new HttpUriRequestBase(httpMethod.name(), uri); } /** diff --git a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java index 4c553a38bdb..527f1c51722 100644 --- a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java @@ -52,6 +52,7 @@ protected ClientHttpRequestFactory createRequestFactory() { void httpMethods() throws Exception { super.httpMethods(); assertHttpMethod("patch", HttpMethod.PATCH); + assertHttpMethod("propfind", HttpMethod.valueOf("PROPFIND")); } @Test