Polishing
This commit is contained in:
parent
d501137f4e
commit
c7e7d11156
|
@ -64,7 +64,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
static {
|
static {
|
||||||
// variable names refer to RFC 2616, section 2.2
|
// variable names refer to RFC 2616, section 2.2
|
||||||
BitSet ctl = new BitSet(128);
|
BitSet ctl = new BitSet(128);
|
||||||
for (int i=0; i <= 31; i++) {
|
for (int i = 0; i <= 31; i++) {
|
||||||
ctl.set(i);
|
ctl.set(i);
|
||||||
}
|
}
|
||||||
ctl.set(127);
|
ctl.set(127);
|
||||||
|
@ -155,14 +155,14 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
this.type = type.toLowerCase(Locale.ENGLISH);
|
this.type = type.toLowerCase(Locale.ENGLISH);
|
||||||
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
||||||
if (!CollectionUtils.isEmpty(parameters)) {
|
if (!CollectionUtils.isEmpty(parameters)) {
|
||||||
Map<String, String> m = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
|
Map<String, String> map = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||||
String attribute = entry.getKey();
|
String attribute = entry.getKey();
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
checkParameters(attribute, value);
|
checkParameters(attribute, value);
|
||||||
m.put(attribute, value);
|
map.put(attribute, value);
|
||||||
}
|
}
|
||||||
this.parameters = Collections.unmodifiableMap(m);
|
this.parameters = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.parameters = Collections.emptyMap();
|
this.parameters = Collections.emptyMap();
|
||||||
|
@ -256,7 +256,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the character set, as indicated by a {@code charset} parameter, if any.
|
* Return the character set, as indicated by a {@code charset} parameter, if any.
|
||||||
* @return the character set; or {@code null} if not available
|
* @return the character set, or {@code null} if not available
|
||||||
*/
|
*/
|
||||||
public Charset getCharSet() {
|
public Charset getCharSet() {
|
||||||
String charSet = getParameter(PARAM_CHARSET);
|
String charSet = getParameter(PARAM_CHARSET);
|
||||||
|
@ -266,7 +266,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
/**
|
/**
|
||||||
* Return a generic parameter value, given a parameter name.
|
* Return a generic parameter value, given a parameter name.
|
||||||
* @param name the parameter name
|
* @param name the parameter name
|
||||||
* @return the parameter value; or {@code null} if not present
|
* @return the parameter value, or {@code null} if not present
|
||||||
*/
|
*/
|
||||||
public String getParameter(String name) {
|
public String getParameter(String name) {
|
||||||
return this.parameters.get(name);
|
return this.parameters.get(name);
|
||||||
|
@ -274,10 +274,10 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all generic parameter values.
|
* Return all generic parameter values.
|
||||||
* @return a read-only map, possibly empty, never {@code null}
|
* @return a read-only map (possibly empty, never {@code null})
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getParameters() {
|
public Map<String, String> getParameters() {
|
||||||
return parameters;
|
return this.parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -362,17 +362,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the list of acceptable {@linkplain MediaType media types}, as specified by the {@code Accept} header.
|
* Set the list of acceptable {@linkplain MediaType media types},
|
||||||
* @param acceptableMediaTypes the acceptable media types
|
* as specified by the {@code Accept} header.
|
||||||
*/
|
*/
|
||||||
public void setAccept(List<MediaType> acceptableMediaTypes) {
|
public void setAccept(List<MediaType> acceptableMediaTypes) {
|
||||||
set(ACCEPT, MediaType.toString(acceptableMediaTypes));
|
set(ACCEPT, MediaType.toString(acceptableMediaTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of acceptable {@linkplain MediaType media types}, as specified by the {@code Accept} header.
|
* Return the list of acceptable {@linkplain MediaType media types},
|
||||||
|
* as specified by the {@code Accept} header.
|
||||||
* <p>Returns an empty list when the acceptable media types are unspecified.
|
* <p>Returns an empty list when the acceptable media types are unspecified.
|
||||||
* @return the acceptable media types
|
|
||||||
*/
|
*/
|
||||||
public List<MediaType> getAccept() {
|
public List<MediaType> getAccept() {
|
||||||
String value = getFirst(ACCEPT);
|
String value = getFirst(ACCEPT);
|
||||||
|
@ -391,8 +391,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the list of acceptable {@linkplain Charset charsets}, as specified by the {@code Accept-Charset} header.
|
* Set the list of acceptable {@linkplain Charset charsets},
|
||||||
* @param acceptableCharsets the acceptable charsets
|
* as specified by the {@code Accept-Charset} header.
|
||||||
*/
|
*/
|
||||||
public void setAcceptCharset(List<Charset> acceptableCharsets) {
|
public void setAcceptCharset(List<Charset> acceptableCharsets) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -407,9 +407,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of acceptable {@linkplain Charset charsets}, as specified by the {@code Accept-Charset}
|
* Return the list of acceptable {@linkplain Charset charsets},
|
||||||
* header.
|
* as specified by the {@code Accept-Charset} header.
|
||||||
* @return the acceptable charsets
|
|
||||||
*/
|
*/
|
||||||
public List<Charset> getAcceptCharset() {
|
public List<Charset> getAcceptCharset() {
|
||||||
List<Charset> result = new ArrayList<Charset>();
|
List<Charset> result = new ArrayList<Charset>();
|
||||||
|
@ -434,17 +433,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header.
|
* Set the set of allowed {@link HttpMethod HTTP methods},
|
||||||
* @param allowedMethods the allowed methods
|
* as specified by the {@code Allow} header.
|
||||||
*/
|
*/
|
||||||
public void setAllow(Set<HttpMethod> allowedMethods) {
|
public void setAllow(Set<HttpMethod> allowedMethods) {
|
||||||
set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods));
|
set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header.
|
* Return the set of allowed {@link HttpMethod HTTP methods},
|
||||||
|
* as specified by the {@code Allow} header.
|
||||||
* <p>Returns an empty set when the allowed methods are unspecified.
|
* <p>Returns an empty set when the allowed methods are unspecified.
|
||||||
* @return the allowed methods
|
|
||||||
*/
|
*/
|
||||||
public Set<HttpMethod> getAllow() {
|
public Set<HttpMethod> getAllow() {
|
||||||
String value = getFirst(ALLOW);
|
String value = getFirst(ALLOW);
|
||||||
|
@ -462,8 +461,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Cache-Control} header.
|
* Set the (new) value of the {@code Cache-Control} header.
|
||||||
* @param cacheControl the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setCacheControl(String cacheControl) {
|
public void setCacheControl(String cacheControl) {
|
||||||
set(CACHE_CONTROL, cacheControl);
|
set(CACHE_CONTROL, cacheControl);
|
||||||
|
@ -471,23 +469,20 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Cache-Control} header.
|
* Returns the value of the {@code Cache-Control} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getCacheControl() {
|
public String getCacheControl() {
|
||||||
return getFirst(CACHE_CONTROL);
|
return getFirst(CACHE_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Connection} header.
|
* Set the (new) value of the {@code Connection} header.
|
||||||
* @param connection the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setConnection(String connection) {
|
public void setConnection(String connection) {
|
||||||
set(CONNECTION, connection);
|
set(CONNECTION, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Connection} header.
|
* Set the (new) value of the {@code Connection} header.
|
||||||
* @param connection the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setConnection(List<String> connection) {
|
public void setConnection(List<String> connection) {
|
||||||
set(CONNECTION, toCommaDelimitedString(connection));
|
set(CONNECTION, toCommaDelimitedString(connection));
|
||||||
|
@ -495,16 +490,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Connection} header.
|
* Returns the value of the {@code Connection} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public List<String> getConnection() {
|
public List<String> getConnection() {
|
||||||
return getFirstValueAsList(CONNECTION);
|
return getFirstValueAsList(CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Content-Disposition} header for {@code form-data}.
|
* Set the (new) value of the {@code Content-Disposition} header for {@code form-data}.
|
||||||
* @param name the control name
|
* @param name the control name
|
||||||
* @param filename the filename, may be {@code null}
|
* @param filename the filename (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public void setContentDispositionFormData(String name, String filename) {
|
public void setContentDispositionFormData(String name, String filename) {
|
||||||
Assert.notNull(name, "'name' must not be null");
|
Assert.notNull(name, "'name' must not be null");
|
||||||
|
@ -518,17 +512,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the length of the body in bytes, as specified by the {@code Content-Length} header.
|
* Set the length of the body in bytes,
|
||||||
* @param contentLength the content length
|
* as specified by the {@code Content-Length} header.
|
||||||
*/
|
*/
|
||||||
public void setContentLength(long contentLength) {
|
public void setContentLength(long contentLength) {
|
||||||
set(CONTENT_LENGTH, Long.toString(contentLength));
|
set(CONTENT_LENGTH, Long.toString(contentLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the length of the body in bytes, as specified by the {@code Content-Length} header.
|
* Return the length of the body in bytes,
|
||||||
|
* as specified by the {@code Content-Length} header.
|
||||||
* <p>Returns -1 when the content-length is unknown.
|
* <p>Returns -1 when the content-length is unknown.
|
||||||
* @return the content length
|
|
||||||
*/
|
*/
|
||||||
public long getContentLength() {
|
public long getContentLength() {
|
||||||
String value = getFirst(CONTENT_LENGTH);
|
String value = getFirst(CONTENT_LENGTH);
|
||||||
|
@ -536,8 +530,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@linkplain MediaType media type} of the body, as specified by the {@code Content-Type} header.
|
* Set the {@linkplain MediaType media type} of the body,
|
||||||
* @param mediaType the media type
|
* as specified by the {@code Content-Type} header.
|
||||||
*/
|
*/
|
||||||
public void setContentType(MediaType mediaType) {
|
public void setContentType(MediaType mediaType) {
|
||||||
Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
|
Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
|
||||||
|
@ -548,7 +542,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
/**
|
/**
|
||||||
* Return the {@linkplain MediaType media type} of the body, as specified by the {@code Content-Type} header.
|
* Return the {@linkplain MediaType media type} of the body, as specified by the {@code Content-Type} header.
|
||||||
* <p>Returns {@code null} when the content-type is unknown.
|
* <p>Returns {@code null} when the content-type is unknown.
|
||||||
* @return the content type
|
|
||||||
*/
|
*/
|
||||||
public MediaType getContentType() {
|
public MediaType getContentType() {
|
||||||
String value = getFirst(CONTENT_TYPE);
|
String value = getFirst(CONTENT_TYPE);
|
||||||
|
@ -556,18 +549,20 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the date and time at which the message was created, as specified by the {@code Date} header.
|
* Set the date and time at which the message was created,
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* as specified by the {@code Date} header.
|
||||||
* @param date the date
|
* <p>The date should be specified as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setDate(long date) {
|
public void setDate(long date) {
|
||||||
setDate(DATE, date);
|
setDate(DATE, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time at which the message was created, as specified by the {@code Date} header.
|
* Returns the date and time at which the message was created,
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* as specified by the {@code Date} header.
|
||||||
* @return the creation date/time
|
* <p>The date is returned as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
* @throws IllegalArgumentException if the value can't be converted to a date
|
* @throws IllegalArgumentException if the value can't be converted to a date
|
||||||
*/
|
*/
|
||||||
public long getDate() {
|
public long getDate() {
|
||||||
|
@ -575,12 +570,12 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) entity tag of the body, as specified by the {@code ETag} header.
|
* Set the (new) entity tag of the body, as specified by the {@code ETag} header.
|
||||||
* @param eTag the new entity tag
|
|
||||||
*/
|
*/
|
||||||
public void setETag(String eTag) {
|
public void setETag(String eTag) {
|
||||||
if (eTag != null) {
|
if (eTag != null) {
|
||||||
Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"), "Invalid eTag, does not start with W/ or \"");
|
Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"),
|
||||||
|
"Invalid eTag, does not start with W/ or \"");
|
||||||
Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
|
Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
|
||||||
}
|
}
|
||||||
set(ETAG, eTag);
|
set(ETAG, eTag);
|
||||||
|
@ -588,27 +583,27 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity tag of the body, as specified by the {@code ETag} header.
|
* Returns the entity tag of the body, as specified by the {@code ETag} header.
|
||||||
* @return the entity tag
|
|
||||||
*/
|
*/
|
||||||
public String getETag() {
|
public String getETag() {
|
||||||
return getFirst(ETAG);
|
return getFirst(ETAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the date and time at which the message is no longer valid, as specified by the {@code Expires} header.
|
* Set the date and time at which the message is no longer valid,
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* as specified by the {@code Expires} header.
|
||||||
* @param expires the new expires header value
|
* <p>The date should be specified as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setExpires(long expires) {
|
public void setExpires(long expires) {
|
||||||
setDate(EXPIRES, expires);
|
setDate(EXPIRES, expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time at which the message is no longer valid, as specified by
|
* Returns the date and time at which the message is no longer valid,
|
||||||
* the {@code Expires} header.
|
* as specified by the {@code Expires} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT.
|
* <p>The date is returned as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT.
|
||||||
* Returns -1 when the date is unknown.
|
* Returns -1 when the date is unknown.
|
||||||
* @return the expires value
|
|
||||||
*/
|
*/
|
||||||
public long getExpires() {
|
public long getExpires() {
|
||||||
try {
|
try {
|
||||||
|
@ -620,9 +615,9 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code If-Modified-Since} header.
|
* Set the (new) value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* <p>The date should be specified as the number of milliseconds
|
||||||
* @param ifModifiedSince the new value of the header
|
* since January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setIfModifiedSince(long ifModifiedSince) {
|
public void setIfModifiedSince(long ifModifiedSince) {
|
||||||
setDate(IF_MODIFIED_SINCE, ifModifiedSince);
|
setDate(IF_MODIFIED_SINCE, ifModifiedSince);
|
||||||
|
@ -630,8 +625,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code IfModifiedSince} header.
|
* Returns the value of the {@code IfModifiedSince} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* <p>The date is returned as the number of milliseconds
|
||||||
* @return the header value
|
* since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
* @deprecated use {@link #getIfModifiedSince()}
|
* @deprecated use {@link #getIfModifiedSince()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -641,24 +636,22 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code If-Modified-Since} header.
|
* Returns the value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* <p>The date is returned as the number of milliseconds
|
||||||
* @return the header value
|
* since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
*/
|
*/
|
||||||
public long getIfModifiedSince() {
|
public long getIfModifiedSince() {
|
||||||
return getFirstDate(IF_MODIFIED_SINCE);
|
return getFirstDate(IF_MODIFIED_SINCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code If-None-Match} header.
|
* Set the (new) value of the {@code If-None-Match} header.
|
||||||
* @param ifNoneMatch the new value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setIfNoneMatch(String ifNoneMatch) {
|
public void setIfNoneMatch(String ifNoneMatch) {
|
||||||
set(IF_NONE_MATCH, ifNoneMatch);
|
set(IF_NONE_MATCH, ifNoneMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) values of the {@code If-None-Match} header.
|
* Set the (new) values of the {@code If-None-Match} header.
|
||||||
* @param ifNoneMatchList the new value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setIfNoneMatch(List<String> ifNoneMatchList) {
|
public void setIfNoneMatch(List<String> ifNoneMatchList) {
|
||||||
set(IF_NONE_MATCH, toCommaDelimitedString(ifNoneMatchList));
|
set(IF_NONE_MATCH, toCommaDelimitedString(ifNoneMatchList));
|
||||||
|
@ -677,8 +670,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code If-None-Match} header.
|
* Return the value of the {@code If-None-Match} header.
|
||||||
* @return the header value
|
|
||||||
*/
|
*/
|
||||||
public List<String> getIfNoneMatch() {
|
public List<String> getIfNoneMatch() {
|
||||||
return getFirstValueAsList(IF_NONE_MATCH);
|
return getFirstValueAsList(IF_NONE_MATCH);
|
||||||
|
@ -686,7 +678,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
protected List<String> getFirstValueAsList(String header) {
|
protected List<String> getFirstValueAsList(String header) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
String value = getFirst(header);
|
String value = getFirst(header);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
String[] tokens = value.split(",\\s*");
|
String[] tokens = value.split(",\\s*");
|
||||||
|
@ -698,35 +689,37 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time the resource was last changed, as specified by the {@code Last-Modified} header.
|
* Set the time the resource was last changed,
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* as specified by the {@code Last-Modified} header.
|
||||||
* @param lastModified the last modified date
|
* <p>The date should be specified as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setLastModified(long lastModified) {
|
public void setLastModified(long lastModified) {
|
||||||
setDate(LAST_MODIFIED, lastModified);
|
setDate(LAST_MODIFIED, lastModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time the resource was last changed, as specified by the {@code Last-Modified} header.
|
* Return the time the resource was last changed,
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* as specified by the {@code Last-Modified} header.
|
||||||
* @return the last modified date
|
* <p>The date is returned as the number of milliseconds
|
||||||
|
* since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
*/
|
*/
|
||||||
public long getLastModified() {
|
public long getLastModified() {
|
||||||
return getFirstDate(LAST_MODIFIED);
|
return getFirstDate(LAST_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (new) location of a resource, as specified by the {@code Location} header.
|
* Set the (new) location of a resource,
|
||||||
* @param location the location
|
* as specified by the {@code Location} header.
|
||||||
*/
|
*/
|
||||||
public void setLocation(URI location) {
|
public void setLocation(URI location) {
|
||||||
set(LOCATION, location.toASCIIString());
|
set(LOCATION, location.toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the (new) location of a resource, as specified by the {@code Location} header.
|
* Return the (new) location of a resource
|
||||||
|
* as specified by the {@code Location} header.
|
||||||
* <p>Returns {@code null} when the location is unknown.
|
* <p>Returns {@code null} when the location is unknown.
|
||||||
* @return the location
|
|
||||||
*/
|
*/
|
||||||
public URI getLocation() {
|
public URI getLocation() {
|
||||||
String value = getFirst(LOCATION);
|
String value = getFirst(LOCATION);
|
||||||
|
@ -734,40 +727,35 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Origin} header.
|
* Set the (new) value of the {@code Origin} header.
|
||||||
* @param origin the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setOrigin(String origin) {
|
public void setOrigin(String origin) {
|
||||||
set(ORIGIN, origin);
|
set(ORIGIN, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Origin} header.
|
* Return the value of the {@code Origin} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getOrigin() {
|
public String getOrigin() {
|
||||||
return getFirst(ORIGIN);
|
return getFirst(ORIGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Pragma} header.
|
* Set the (new) value of the {@code Pragma} header.
|
||||||
* @param pragma the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setPragma(String pragma) {
|
public void setPragma(String pragma) {
|
||||||
set(PRAGMA, pragma);
|
set(PRAGMA, pragma);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Pragma} header.
|
* Return the value of the {@code Pragma} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getPragma() {
|
public String getPragma() {
|
||||||
return getFirst(PRAGMA);
|
return getFirst(PRAGMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Upgrade} header.
|
* Set the (new) value of the {@code Upgrade} header.
|
||||||
* @param upgrade the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setUpgrade(String upgrade) {
|
public void setUpgrade(String upgrade) {
|
||||||
set(UPGRADE, upgrade);
|
set(UPGRADE, upgrade);
|
||||||
|
@ -775,7 +763,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Upgrade} header.
|
* Returns the value of the {@code Upgrade} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getUpgrade() {
|
public String getUpgrade() {
|
||||||
return getFirst(UPGRADE);
|
return getFirst(UPGRADE);
|
||||||
|
@ -819,7 +806,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
/**
|
/**
|
||||||
* Return the first header value for the given header name, if any.
|
* Return the first header value for the given header name, if any.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @return the first header value; or {@code null}
|
* @return the first header value, or {@code null} if none
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getFirst(String headerName) {
|
public String getFirst(String headerName) {
|
||||||
|
@ -829,7 +816,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given, single header value under the given name.
|
* Add the given, single header value under the given name.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @param headerValue the header value
|
* @param headerValue the header value
|
||||||
* @throws UnsupportedOperationException if adding headers is not supported
|
* @throws UnsupportedOperationException if adding headers is not supported
|
||||||
* @see #put(String, List)
|
* @see #put(String, List)
|
||||||
|
@ -847,7 +834,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the given, single header value under the given name.
|
* Set the given, single header value under the given name.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @param headerValue the header value
|
* @param headerValue the header value
|
||||||
* @throws UnsupportedOperationException if adding headers is not supported
|
* @throws UnsupportedOperationException if adding headers is not supported
|
||||||
* @see #put(String, List)
|
* @see #put(String, List)
|
||||||
|
@ -915,8 +902,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ? extends List<String>> m) {
|
public void putAll(Map<? extends String, ? extends List<String>> map) {
|
||||||
this.headers.putAll(m);
|
this.headers.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.springframework.http;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
@ -377,7 +377,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BodyBuilder allow(HttpMethod... allowedMethods) {
|
public BodyBuilder allow(HttpMethod... allowedMethods) {
|
||||||
this.headers.setAllow(new HashSet<HttpMethod>(Arrays.asList(allowedMethods)));
|
this.headers.setAllow(new LinkedHashSet<HttpMethod>(Arrays.asList(allowedMethods)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue