@@ -385,7 +385,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
385
385
* An empty {@code HttpHeaders} instance (immutable).
386
386
* @since 5.0
387
387
*/
388
- public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders (new HttpHeaders ( new LinkedMultiValueMap <>(0 ) ));
388
+ public static final HttpHeaders EMPTY = new ReadOnlyHttpHeaders (new LinkedMultiValueMap <>());
389
389
390
390
/**
391
391
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
@@ -1769,17 +1769,21 @@ public String toString() {
1769
1769
1770
1770
1771
1771
/**
1772
- * Apply a read-only {@code HttpHeaders} wrapper around the given headers.
1772
+ * Apply a read-only {@code HttpHeaders} wrapper around the given headers,
1773
+ * if necessary.
1774
+ * @param headers the headers to expose
1775
+ * @return a read-only variant of the headers, or the original headers as-is
1773
1776
*/
1774
- public static HttpHeaders readOnlyHttpHeaders (MultiValueMap < String , String > headers ) {
1777
+ public static HttpHeaders readOnlyHttpHeaders (HttpHeaders headers ) {
1775
1778
Assert .notNull (headers , "HttpHeaders must not be null" );
1776
- return (headers instanceof ReadOnlyHttpHeaders ?
1777
- (HttpHeaders ) headers : new ReadOnlyHttpHeaders (headers ));
1779
+ return (headers instanceof ReadOnlyHttpHeaders ? headers : new ReadOnlyHttpHeaders (headers .headers ));
1778
1780
}
1779
1781
1780
1782
/**
1781
1783
* Remove any read-only wrapper that may have been previously applied around
1782
- * the given headers via {@link #readOnlyHttpHeaders(MultiValueMap)}.
1784
+ * the given headers via {@link #readOnlyHttpHeaders(HttpHeaders)}.
1785
+ * @param headers the headers to expose
1786
+ * @return a writable variant of the headers, or the original headers as-is
1783
1787
* @since 5.1.1
1784
1788
*/
1785
1789
public static HttpHeaders writableHttpHeaders (HttpHeaders headers ) {
0 commit comments