|
|
|
|
@ -1747,8 +1747,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@@ -1747,8 +1747,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|
|
|
|
if (!(other instanceof HttpHeaders)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
HttpHeaders otherHeaders = (HttpHeaders) other; |
|
|
|
|
return this.headers.equals(otherHeaders.headers); |
|
|
|
|
return unwrap(this).equals(unwrap((HttpHeaders) other)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) { |
|
|
|
|
while (headers.headers instanceof HttpHeaders) { |
|
|
|
|
headers = (HttpHeaders) headers.headers; |
|
|
|
|
} |
|
|
|
|
return headers.headers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -1763,20 +1769,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@@ -1763,20 +1769,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return an {@code HttpHeaders} object that can only be read, not written to. |
|
|
|
|
* Apply a read-only {@code HttpHeaders} wrapper around the given headers. |
|
|
|
|
*/ |
|
|
|
|
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) { |
|
|
|
|
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) { |
|
|
|
|
Assert.notNull(headers, "HttpHeaders must not be null"); |
|
|
|
|
if (headers instanceof ReadOnlyHttpHeaders) { |
|
|
|
|
return headers; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return new ReadOnlyHttpHeaders(headers); |
|
|
|
|
} |
|
|
|
|
return (headers instanceof ReadOnlyHttpHeaders ? |
|
|
|
|
(HttpHeaders) headers : new ReadOnlyHttpHeaders(headers)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return an {@code HttpHeaders} object that can be read and written to. |
|
|
|
|
* Remove any read-only wrapper that may have been previously applied around |
|
|
|
|
* the given headers via {@link #readOnlyHttpHeaders(MultiValueMap)}. |
|
|
|
|
* @since 5.1.1 |
|
|
|
|
*/ |
|
|
|
|
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) { |
|
|
|
|
@ -1784,12 +1787,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
@@ -1784,12 +1787,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|
|
|
|
if (headers == EMPTY) { |
|
|
|
|
return new HttpHeaders(); |
|
|
|
|
} |
|
|
|
|
else if (headers instanceof ReadOnlyHttpHeaders) { |
|
|
|
|
return new HttpHeaders(headers.headers); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return headers; |
|
|
|
|
} |
|
|
|
|
return (headers instanceof ReadOnlyHttpHeaders ? new HttpHeaders(headers.headers) : headers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|