Skip to content

Commit

Permalink
Fix and add comments to HttpUtil
Browse files Browse the repository at this point in the history
Motivation:
The comments in HttpUtil need some love.

Modifications
- Update comments in HttpUtil

Result:
Comments are cleaner in HttpUtil.
  • Loading branch information
Scottmitch committed Aug 27, 2015
1 parent fcd8a3e commit 52b77a7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static boolean isAsteriskForm(URI uri) {

/**
* 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
* {@link HttpVersion#isKeepAliveDefault()}.
*/
Expand All @@ -68,7 +68,7 @@ public static boolean isKeepAlive(HttpMessage message) {

/**
* 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
* mode of the message's protocol version is, as specified by
* {@link HttpVersion#isKeepAliveDefault()}.
Expand Down Expand Up @@ -103,7 +103,7 @@ public static void setKeepAlive(HttpMessage message, boolean keepAlive) {
}

/**
* 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
* {@code "Content-Length"} header, and thus they are independent from each
* other.
Expand Down Expand Up @@ -132,7 +132,7 @@ public static long getContentLength(HttpMessage message) {
}

/**
* 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
* {@code "Content-Length"} header, and thus they are independent from each
* other.
Expand Down Expand Up @@ -169,7 +169,7 @@ public static int getContentLength(HttpMessage message, int defaultValue) {
}

/**
* 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.
*/
private static int getWebSocketContentLength(HttpMessage message) {
Expand Down Expand Up @@ -236,7 +236,7 @@ public static boolean is100ContinueExpected(HttpMessage message) {

/**
* 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
* {@code "Expect"} headers are removed. Otherwise, all {@code "Expect"}
* headers are removed completely.
Expand All @@ -259,6 +259,13 @@ public static boolean isTransferEncodingChunked(HttpMessage message) {
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) {
if (chunked) {
m.headers().add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
Expand Down

0 comments on commit 52b77a7

Please sign in to comment.