diff --git a/spring-web/src/main/java/org/springframework/http/CacheControl.java b/spring-web/src/main/java/org/springframework/http/CacheControl.java index a9b4aea11c..315dd0a4d3 100644 --- a/spring-web/src/main/java/org/springframework/http/CacheControl.java +++ b/spring-web/src/main/java/org/springframework/http/CacheControl.java @@ -252,47 +252,47 @@ public class CacheControl { /** - * Return the "Cache-Control" header value. - * @return {@code null} if no directive was added, or the header value otherwise + * Return the "Cache-Control" header value, if any. + * @return the header value, or {@code null} if no directive was added */ public String getHeaderValue() { - StringBuilder ccValue = new StringBuilder(); + StringBuilder headerValue = new StringBuilder(); if (this.maxAge != -1) { - appendDirective(ccValue, "max-age=" + Long.toString(this.maxAge)); + appendDirective(headerValue, "max-age=" + this.maxAge); } if (this.noCache) { - appendDirective(ccValue, "no-cache"); + appendDirective(headerValue, "no-cache"); } if (this.noStore) { - appendDirective(ccValue, "no-store"); + appendDirective(headerValue, "no-store"); } if (this.mustRevalidate) { - appendDirective(ccValue, "must-revalidate"); + appendDirective(headerValue, "must-revalidate"); } if (this.noTransform) { - appendDirective(ccValue, "no-transform"); + appendDirective(headerValue, "no-transform"); } if (this.cachePublic) { - appendDirective(ccValue, "public"); + appendDirective(headerValue, "public"); } if (this.cachePrivate) { - appendDirective(ccValue, "private"); + appendDirective(headerValue, "private"); } if (this.proxyRevalidate) { - appendDirective(ccValue, "proxy-revalidate"); + appendDirective(headerValue, "proxy-revalidate"); } if (this.sMaxAge != -1) { - appendDirective(ccValue, "s-maxage=" + Long.toString(this.sMaxAge)); + appendDirective(headerValue, "s-maxage=" + this.sMaxAge); } if (this.staleIfError != -1) { - appendDirective(ccValue, "stale-if-error=" + Long.toString(this.staleIfError)); + appendDirective(headerValue, "stale-if-error=" + this.staleIfError); } if (this.staleWhileRevalidate != -1) { - appendDirective(ccValue, "stale-while-revalidate=" + Long.toString(this.staleWhileRevalidate)); + appendDirective(headerValue, "stale-while-revalidate=" + this.staleWhileRevalidate); } - String ccHeaderValue = ccValue.toString(); - return (StringUtils.hasText(ccHeaderValue) ? ccHeaderValue : null); + String valueString = headerValue.toString(); + return (StringUtils.hasText(valueString) ? valueString : null); } private void appendDirective(StringBuilder builder, String value) { diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index bca45349b5..690b276306 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -43,18 +43,17 @@ import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; /** - * Represents HTTP request and response headers, mapping string header names to a list of string values. + * A data structure representing HTTP request or response headers, mapping String header names + * to a list of String values, also offering accessors for common application-level data types. * - *
In addition to the normal methods defined by {@link Map}, this class offers the following - * convenience methods: + *
In addition to the regular methods defined by {@link Map}, this class offers many common + * convenience methods, for example: *
Inspired by {@code com.sun.net.httpserver.Headers}.
- *
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @author Brian Clozel
@@ -66,6 +65,7 @@ public class HttpHeaders implements MultiValueMap>(8, Locale.ENGLISH), false);
@@ -744,8 +744,8 @@ public class HttpHeaders implements MultiValueMap