Polishing

(cherry picked from commit 3767092)
This commit is contained in:
Juergen Hoeller
2016-08-31 01:53:03 +02:00
parent 31c5644691
commit ab9fea6b8d
6 changed files with 51 additions and 40 deletions

View File

@@ -808,13 +808,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
/**
* Set the (new) value of the {@code Host} header.
* <p>If the given {@linkplain InetSocketAddress#getPort() port} is {@code 0}, the host header
* will only contain the {@linkplain InetSocketAddress#getHostString() hostname}.
* <p>If the given {@linkplain InetSocketAddress#getPort() port} is {@code 0},
* the host header will only contain the
* {@linkplain InetSocketAddress#getHostString() hostname}.
* @since 5.0
*/
public void setHost(InetSocketAddress host) {
String value =
host.getPort() != 0 ? String.format("%s:%d", host.getHostString(), host.getPort()) :
host.getHostString();
String value = (host.getPort() != 0 ?
String.format("%s:%d", host.getHostString(), host.getPort()) : host.getHostString());
set(HOST, value);
}
@@ -822,6 +823,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* Return the value of the required {@code Host} header.
* <p>If the header value does not contain a port, the returned
* {@linkplain InetSocketAddress#getPort() port} will be {@code 0}.
* @since 5.0
*/
public InetSocketAddress getHost() {
String value = getFirst(HOST);

View File

@@ -56,8 +56,8 @@ public abstract class HttpRange {
public ResourceRegion toResourceRegion(Resource resource) {
// Don't try to determine contentLength on InputStreamResource - cannot be read afterwards...
// Note: custom InputStreamResource subclasses could provide a pre-calculated content length!
Assert.isTrue(InputStreamResource.class != resource.getClass(),
"Can't convert an InputStreamResource to a ResourceRegion");
Assert.isTrue(resource.getClass() != InputStreamResource.class,
"Cannot convert an InputStreamResource to a ResourceRegion");
try {
long contentLength = resource.contentLength();
Assert.isTrue(contentLength > 0, "Resource content length should be > 0");
@@ -163,12 +163,12 @@ public abstract class HttpRange {
}
/**
* Convert each {@code HttpRange} into a {@code ResourceRegion},
* selecting the appropriate segment of the given {@code Resource}
* using the HTTP Range information.
* Convert each {@code HttpRange} into a {@code ResourceRegion}, selecting the
* appropriate segment of the given {@code Resource} using HTTP Range information.
* @param ranges the list of ranges
* @param resource the resource to select the regions from
* @return the list of regions for the given resource
* @since 4.3
*/
public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) {
if (CollectionUtils.isEmpty(ranges)) {

View File

@@ -114,11 +114,13 @@ public class MediaType extends MimeType implements Serializable {
/**
* Public constant media type for {@code application/pdf}.
* @since 4.3
*/
public final static MediaType APPLICATION_PDF;
/**
* A String equivalent of {@link MediaType#APPLICATION_PDF}.
* @since 4.3
*/
public final static String APPLICATION_PDF_VALUE = "application/pdf";
@@ -194,11 +196,13 @@ public class MediaType extends MimeType implements Serializable {
/**
* Public constant media type for {@code text/markdown}.
* @since 4.3
*/
public final static MediaType TEXT_MARKDOWN;
/**
* A String equivalent of {@link MediaType#TEXT_MARKDOWN}.
* @since 4.3
*/
public final static String TEXT_MARKDOWN_VALUE = "text/markdown";
@@ -296,6 +300,7 @@ public class MediaType extends MimeType implements Serializable {
* @param other the other media type
* @param charset the character set
* @throws IllegalArgumentException if any of the parameters contain illegal characters
* @since 4.3
*/
public MediaType(MediaType other, Charset charset) {
super(other, charset);