Skip to content

Commit 3da645f

Browse files
committed
Merge branch '6.2.x'
2 parents 00cc48d + 8dee7d8 commit 3da645f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private static Mono<MultiValueMap<String, String>> initFormData(ServerHttpReques
151151
return EMPTY_FORM_DATA;
152152
}
153153

154-
HttpMessageReader<MultiValueMap<String, String>> reader = getReader(configurer, contentType, FORM_DATA_TYPE);
154+
HttpMessageReader<MultiValueMap<String, String>> reader = getReader(configurer, MediaType.APPLICATION_FORM_URLENCODED, FORM_DATA_TYPE);
155155
if (reader == null) {
156156
return Mono.error(new IllegalStateException("No HttpMessageReader for " + contentType));
157157
}

spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,10 @@
1818

1919
import org.junit.jupiter.api.Test;
2020

21+
import org.springframework.http.HttpHeaders;
22+
import org.springframework.http.MediaType;
2123
import org.springframework.http.codec.ServerCodecConfigurer;
24+
import org.springframework.util.MultiValueMap;
2225
import org.springframework.web.server.ServerWebExchange;
2326
import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
2427
import org.springframework.web.server.session.DefaultWebSessionManager;
@@ -56,6 +59,17 @@ void transformUrlWithMultipleEncoders() {
5659
assertThat(exchange.transformUrl("/foo")).isEqualTo("/foo;p=abc?q=123");
5760
}
5861

62+
@Test // gh-34660
63+
void useFormDataMessageReaderWhenAllContentType() {
64+
MockServerHttpRequest request = MockServerHttpRequest
65+
.post("https://example.com")
66+
.header(HttpHeaders.CONTENT_TYPE, MediaType.ALL_VALUE)
67+
.body("project=spring");
68+
ServerWebExchange exchange = createExchange(request);
69+
MultiValueMap<String, String> body = exchange.getFormData().block();
70+
assertThat(body.get("project")).contains("spring");
71+
}
72+
5973

6074
private DefaultServerWebExchange createExchange() {
6175
MockServerHttpRequest request = MockServerHttpRequest.get("https://example.com").build();

0 commit comments

Comments
 (0)