From eb3bfc0d65da575871e92cbecde842527611f2cc Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 29 Dec 2025 10:52:58 +0100 Subject: [PATCH] Document HttpHeaders#toSingleValueMap() case-sensitive behavior This commit updates the `HttpHeaders` javadoc to better reflect that `asSingleValueMap()`, `asMultiValueMap()`, and `toSingleValueMap()` all return case-sentitive map implementations. Closes gh-36070 --- .../org/springframework/http/HttpHeaders.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index 7342cf0e777..24d811e867f 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1841,11 +1841,12 @@ public class HttpHeaders implements Serializable { /** * Return this HttpHeaders as a {@code Map} with the first values for each - * header name. + * header name. This method is susceptible to include multiple + * casing variants of a given header name, see {@link #asMultiValueMap()} + * javadoc. *

The difference between this method and {@link #asSingleValueMap()} is * that this method returns a copy of the headers, whereas the latter - * returns a view. This copy also ensures that collection-iterating methods - * like {@code entrySet()} are case-insensitive. + * returns a view. * @return a single value representation of these headers */ public Map toSingleValueMap() { @@ -1854,16 +1855,14 @@ public class HttpHeaders implements Serializable { /** * Return this HttpHeaders as a {@code Map} with the first values for each - * header name. - *

The difference between this method and {@link #toSingleValueMap()} is - * that this method returns a view of the headers, whereas the latter - * returns a copy. This method is also susceptible to include multiple + * header name. This method is susceptible to include multiple * casing variants of a given header name, see {@link #asMultiValueMap()} * javadoc. + *

The difference between this method and {@link #toSingleValueMap()} is + * that this method returns a view of the headers, whereas the latter + * returns a copy. * @return a single value representation of these headers - * @deprecated in favor of {@link #toSingleValueMap()} which performs a copy but - * ensures that collection-iterating methods like {@code entrySet()} are - * case-insensitive + * @deprecated in favor of {@link #toSingleValueMap()} which performs a copy */ @Deprecated(since = "7.0", forRemoval = true) public Map asSingleValueMap() {