This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new af2b33a2d5 fix(httpclient): apply deduplicated WebClient headers
(#7083)
af2b33a2d5 is described below
commit af2b33a2d53259de79f86ca225dd4d277400ec38
Author: Liming Deng <[email protected]>
AuthorDate: Thu Oct 1 20:46:51 2026 +0800
fix(httpclient): apply deduplicated WebClient headers (#7083)
---
.../plugin/httpclient/WebClientPluginTest.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git
a/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/WebClientPluginTest.java
b/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/WebClientPluginTest.java
index 7072002e33..5a8f66d568 100644
---
a/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/WebClientPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/WebClientPluginTest.java
@@ -18,10 +18,10 @@
package org.apache.shenyu.plugin.httpclient;
import org.apache.shenyu.common.constant.Constants;
-import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.enums.HeaderUniqueStrategyEnum;
-import org.apache.shenyu.common.enums.UniqueHeaderEnum;
+import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.enums.RpcTypeEnum;
+import org.apache.shenyu.common.enums.UniqueHeaderEnum;
import org.apache.shenyu.common.enums.RetryEnum;
import
org.apache.shenyu.plugin.httpclient.exception.ShenyuUpstreamStatusException;
import org.apache.shenyu.plugin.api.ShenyuPluginChain;
@@ -188,6 +188,25 @@ public final class WebClientPluginTest {
.verify();
}
+ /**
+ * Test that request headers use the configured deduplication strategy.
+ */
+ @Test
+ public void testRequestHeadersAreDeduplicated() {
+ final String headerName = "X-Test-Header";
+ final ServerWebExchange exchange =
MockServerWebExchange.from(MockServerHttpRequest.get("/test")
+ .header(headerName, "first", "last")
+ .build());
+
exchange.getAttributes().put(UniqueHeaderEnum.REQ_UNIQUE_HEADER.getName(),
headerName);
+
exchange.getAttributes().put(UniqueHeaderEnum.REQ_UNIQUE_HEADER.getStrategy(),
HeaderUniqueStrategyEnum.RETAIN_LAST);
+
+ StepVerifier.create(webClientPlugin.doRequest(exchange,
HttpMethod.GET.name(), URI.create("/test"), Flux.empty()))
+ .expectNextCount(1)
+ .verifyComplete();
+
+ assertEquals(Collections.singletonList("last"),
captor.getValue().headers().get(headerName));
+ }
+
@Test
public void testServerErrorTriggersFailover() {
WebClientPlugin plugin = new WebClientPlugin(mockWebClientError(),
Constants.BYTES_PER_MB);
@@ -250,6 +269,7 @@ public final class WebClientPluginTest {
final ClientResponse mockResponse = mock(ClientResponse.class);
when(mockResponse.statusCode()).thenReturn(HttpStatus.OK);
when(mockResponse.headers()).thenReturn(headers);
+
when(mockResponse.bodyToFlux(DataBuffer.class)).thenReturn(Flux.empty());
when(mockResponse.bodyToMono(byte[].class)).thenReturn(Mono.just("{\"test\":\"ok\"}".getBytes()));
when(mockResponse.releaseBody()).thenReturn(Mono.empty());
given(this.exchangeFunction.exchange(this.captor.capture())).willReturn(Mono.just(mockResponse));