Polishing

This commit is contained in:
Juergen Hoeller
2020-06-06 16:10:20 +02:00
parent 5051d7302d
commit 65b09be669
3 changed files with 16 additions and 9 deletions

View File

@@ -1768,6 +1768,19 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
}
/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers, if necessary.
* <p>Also caches the parsed representations of the "Accept" and "Content-Type" headers.
* @param headers the headers to expose
* @return a read-only variant of the headers, or the original headers as-is
* (in case it happens to be a read-only {@code HttpHeaders} instance already)
* @since 5.3
*/
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
return (headers instanceof HttpHeaders ?
readOnlyHttpHeaders((HttpHeaders) headers) : new ReadOnlyHttpHeaders(headers));
}
/**
* Apply a read-only {@code HttpHeaders} wrapper around the given headers, if necessary.
* <p>Also caches the parsed representations of the "Accept" and "Content-Type" headers.