Fix and add comments to HttpUtil

Motivation:
The comments in HttpUtil need some love.

Modifications
- Update comments in HttpUtil

Result:
Comments are cleaner in HttpUtil.
This commit is contained in:
Scott Mitchell 2015-08-27 09:24:45 -07:00
parent b6a4f5de9d
commit 5498fd12dc

View File

@ -50,7 +50,7 @@ public final class HttpUtil {
/** /**
* Returns {@code true} if and only if the connection can remain open and * Returns {@code true} if and only if the connection can remain open and
* thus 'kept alive'. This methods respects the value of the * thus 'kept alive'. This methods respects the value of the.
* {@code "Connection"} header first and then the return value of * {@code "Connection"} header first and then the return value of
* {@link HttpVersion#isKeepAliveDefault()}. * {@link HttpVersion#isKeepAliveDefault()}.
*/ */
@ -69,7 +69,7 @@ public final class HttpUtil {
/** /**
* Sets the value of the {@code "Connection"} header depending on the * Sets the value of the {@code "Connection"} header depending on the
* protocol version of the specified message. This getMethod sets or removes * protocol version of the specified message. This getMethod sets or removes
* the {@code "Connection"} header depending on what the default keep alive * the {@code "Connection"} header depending on what the default keep alive
* mode of the message's protocol version is, as specified by * mode of the message's protocol version is, as specified by
* {@link HttpVersion#isKeepAliveDefault()}. * {@link HttpVersion#isKeepAliveDefault()}.
@ -104,7 +104,7 @@ public final class HttpUtil {
} }
/** /**
* Returns the length of the content. Please note that this value is * Returns the length of the content. Please note that this value is
* not retrieved from {@link HttpContent#content()} but from the * not retrieved from {@link HttpContent#content()} but from the
* {@code "Content-Length"} header, and thus they are independent from each * {@code "Content-Length"} header, and thus they are independent from each
* other. * other.
@ -133,7 +133,7 @@ public final class HttpUtil {
} }
/** /**
* Returns the length of the content. Please note that this value is * Returns the length of the content. Please note that this value is
* not retrieved from {@link HttpContent#content()} but from the * not retrieved from {@link HttpContent#content()} but from the
* {@code "Content-Length"} header, and thus they are independent from each * {@code "Content-Length"} header, and thus they are independent from each
* other. * other.
@ -170,7 +170,7 @@ public final class HttpUtil {
} }
/** /**
* Returns the content length of the specified web socket message. If the * Returns the content length of the specified web socket message. If the
* specified message is not a web socket message, {@code -1} is returned. * specified message is not a web socket message, {@code -1} is returned.
*/ */
private static int getWebSocketContentLength(HttpMessage message) { private static int getWebSocketContentLength(HttpMessage message) {
@ -237,7 +237,7 @@ public final class HttpUtil {
/** /**
* Sets or removes the {@code "Expect: 100-continue"} header to / from the * Sets or removes the {@code "Expect: 100-continue"} header to / from the
* specified message. If the specified {@code value} is {@code true}, * specified message. If the specified {@code value} is {@code true},
* the {@code "Expect: 100-continue"} header is set and all other previous * the {@code "Expect: 100-continue"} header is set and all other previous
* {@code "Expect"} headers are removed. Otherwise, all {@code "Expect"} * {@code "Expect"} headers are removed. Otherwise, all {@code "Expect"}
* headers are removed completely. * headers are removed completely.
@ -260,6 +260,13 @@ public final class HttpUtil {
return message.headers().contains(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED, true); return message.headers().contains(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED, true);
} }
/**
* Set the {@link HttpHeaderNames#TRANSFER_ENCODING} to either include {@link HttpHeaderValues#CHUNKED} if
* {@code chunked} is {@code true}, or remove {@link HttpHeaderValues#CHUNKED} if {@code chunked} is {@code false}.
* @param m The message which contains the headers to modify.
* @param chunked if {@code true} then include {@link HttpHeaderValues#CHUNKED} in the headers. otherwise remove
* {@link HttpHeaderValues#CHUNKED} from the headers.
*/
public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) { public static void setTransferEncodingChunked(HttpMessage m, boolean chunked) {
if (chunked) { if (chunked) {
m.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED); m.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);