Browse Source

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
pull/36079/head
Brian Clozel 4 weeks ago
parent
commit
eb3bfc0d65
  1. 19
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java

19
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -1841,11 +1841,12 @@ public class HttpHeaders implements Serializable { @@ -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.
* <p>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<String, String> toSingleValueMap() {
@ -1854,16 +1855,14 @@ public class HttpHeaders implements Serializable { @@ -1854,16 +1855,14 @@ public class HttpHeaders implements Serializable {
/**
* Return this HttpHeaders as a {@code Map} with the first values for each
* header name.
* <p>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.
* <p>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<String, String> asSingleValueMap() {

Loading…
Cancel
Save