mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Fix HttpHeaders and WebSocketHttpHeaders interop issues
Since HttpHeaders no longer implements MultiValueMap (see gh-33913), a few interoperability issues have arisen between HttpHeaders and WebSocketHttpHeaders. To address those issues, this commit: - Revises addAll(HttpHeaders), putAll(HttpHeaders), and putAll(Map) in HttpHeaders so that they no longer operate on the HttpHeaders.headers field. - Overrides addAll(String, List), asSingleValueMap(), and asMultiValueMap() in WebSocketHttpHeaders. - Deletes putAll(HttpHeaders), putAll(Map), and forEach(BiConsumer) in WebSocketHttpHeaders, since they do not need to be overridden. This commit also removes unnecessarily overridden Javadoc in WebSocketHttpHeaders and revises the implementation of several methods in HttpHeaders so that they delegate to key methods such as get() instead of directly accessing the HttpHeaders.headers field. See gh-33913 Closes gh-35792
This commit is contained in:
@@ -1686,13 +1686,13 @@ public class HttpHeaders implements Serializable {
|
||||
* @since 5.2.3
|
||||
*/
|
||||
public void clearContentHeaders() {
|
||||
this.headers.remove(HttpHeaders.CONTENT_DISPOSITION);
|
||||
this.headers.remove(HttpHeaders.CONTENT_ENCODING);
|
||||
this.headers.remove(HttpHeaders.CONTENT_LANGUAGE);
|
||||
this.headers.remove(HttpHeaders.CONTENT_LENGTH);
|
||||
this.headers.remove(HttpHeaders.CONTENT_LOCATION);
|
||||
this.headers.remove(HttpHeaders.CONTENT_RANGE);
|
||||
this.headers.remove(HttpHeaders.CONTENT_TYPE);
|
||||
remove(HttpHeaders.CONTENT_DISPOSITION);
|
||||
remove(HttpHeaders.CONTENT_ENCODING);
|
||||
remove(HttpHeaders.CONTENT_LANGUAGE);
|
||||
remove(HttpHeaders.CONTENT_LENGTH);
|
||||
remove(HttpHeaders.CONTENT_LOCATION);
|
||||
remove(HttpHeaders.CONTENT_RANGE);
|
||||
remove(HttpHeaders.CONTENT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1807,7 +1807,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @see #putAll(HttpHeaders)
|
||||
*/
|
||||
public void addAll(HttpHeaders headers) {
|
||||
this.headers.addAll(headers.headers);
|
||||
headers.forEach(this::addAll);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1909,7 +1909,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @since 7.0
|
||||
*/
|
||||
public boolean hasHeaderValues(String headerName, List<String> values) {
|
||||
return ObjectUtils.nullSafeEquals(this.headers.get(headerName), values);
|
||||
return ObjectUtils.nullSafeEquals(get(headerName), values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1920,7 +1920,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @since 7.0
|
||||
*/
|
||||
public boolean containsHeaderValue(String headerName, String value) {
|
||||
final List<String> values = this.headers.get(headerName);
|
||||
List<String> values = get(headerName);
|
||||
if (values == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -1969,7 +1969,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @see #put(String, List)
|
||||
*/
|
||||
public void putAll(HttpHeaders headers) {
|
||||
this.headers.putAll(headers.headers);
|
||||
headers.forEach(this::put);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1978,7 +1978,7 @@ public class HttpHeaders implements Serializable {
|
||||
* @see #put(String, List)
|
||||
*/
|
||||
public void putAll(Map<? extends String, ? extends List<String>> headers) {
|
||||
this.headers.putAll(headers);
|
||||
headers.forEach(this::put);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user