Skip to content

Commit

Permalink
Restore original readOnlyHttpHeaders signature for binary compatibility
Browse files Browse the repository at this point in the history
Closes gh-25034
  • Loading branch information
jhoeller committed Jun 6, 2020
1 parent f81b1de commit 4b78903
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions spring-web/src/main/java/org/springframework/http/HttpHeaders.java
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -383,7 +383,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* An empty {@code HttpHeaders} instance (immutable).
* @since 5.0
*/
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new HttpHeaders(new LinkedMultiValueMap<>(0)));
public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders(new LinkedMultiValueMap<>());

/**
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
Expand Down Expand Up @@ -1085,6 +1085,7 @@ public void setIfMatch(List<String> ifMatchList) {

/**
* Return the value of the {@code If-Match} header.
* @throws IllegalArgumentException if parsing fails
* @since 4.3
*/
public List<String> getIfMatch() {
Expand Down Expand Up @@ -1144,6 +1145,7 @@ public void setIfNoneMatch(List<String> ifNoneMatchList) {

/**
* Return the value of the {@code If-None-Match} header.
* @throws IllegalArgumentException if parsing fails
*/
public List<String> getIfNoneMatch() {
return getETagValuesAsList(IF_NONE_MATCH);
Expand Down Expand Up @@ -1471,6 +1473,7 @@ public List<String> getValuesAsList(String headerName) {
* Retrieve a combined result from the field values of the ETag header.
* @param headerName the header name
* @return the combined result
* @throws IllegalArgumentException if parsing fails
* @since 4.3
*/
protected List<String> getETagValuesAsList(String headerName) {
Expand Down Expand Up @@ -1699,17 +1702,21 @@ public String toString() {


/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers.
* Apply a read-only {@code HttpHeaders} wrapper around the given headers,
* if necessary.
* @param headers the headers to expose
* @return a read-only variant of the headers, or the original headers as-is
*/
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
Assert.notNull(headers, "HttpHeaders must not be null");
return (headers instanceof ReadOnlyHttpHeaders ?
(HttpHeaders) headers : new ReadOnlyHttpHeaders(headers));
return (headers instanceof ReadOnlyHttpHeaders ? headers : new ReadOnlyHttpHeaders(headers.headers));
}

/**
* Remove any read-only wrapper that may have been previously applied around
* the given headers via {@link #readOnlyHttpHeaders(MultiValueMap)}.
* the given headers via {@link #readOnlyHttpHeaders(HttpHeaders)}.
* @param headers the headers to expose
* @return a writable variant of the headers, or the original headers as-is
* @since 5.1.1
*/
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {
Expand Down

0 comments on commit 4b78903

Please sign in to comment.