public class HttpMessageContents
extends java.lang.Object
HttpMessage. Contains convenience methods to extract and
manipulate the contents of the wrapped HttpMessage.
TODO: Currently this class only wraps FullHttpMessages, since it must modify the Content-Length header; determine if this may be applied to chunked messages as well| Constructor and Description |
|---|
HttpMessageContents(io.netty.handler.codec.http.FullHttpMessage httpMessage) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBinaryContents()
Retrieves the binary contents of this message.
|
java.nio.charset.Charset |
getCharset()
Retrieves the character set of the entity body.
|
java.lang.String |
getContentType()
Retrieves the Content-Type header of this message.
|
java.lang.String |
getTextContents()
Retrieves the contents of this message as a String, decoded according to the message's Content-Type header.
|
boolean |
isText()
Returns true if this message's Content-Type header indicates that it contains a textual data type.
|
void |
setBinaryContents(byte[] newBinaryContents)
Replaces the contents of the wrapped HttpMessage with the specified binary contents.
|
void |
setTextContents(java.lang.String newContents)
Replaces the contents of the wrapped HttpMessage with the specified text contents, encoding them in the character set specified by the
message's Content-Type header.
|
public HttpMessageContents(io.netty.handler.codec.http.FullHttpMessage httpMessage)
public void setTextContents(java.lang.String newContents)
newContents - new message contentspublic void setBinaryContents(byte[] newBinaryContents)
newBinaryContents - new message contentspublic java.lang.String getTextContents()
throws java.nio.charset.UnsupportedCharsetException
java.nio.charset.UnsupportedCharsetException - if the character set declared in the message is not supported on this platformpublic byte[] getBinaryContents()
public java.lang.String getContentType()
BrowserUpHttpUtil.UNKNOWN_CONTENT_TYPE).public java.nio.charset.Charset getCharset()
throws java.nio.charset.UnsupportedCharsetException
UnsupportedCharsetException.java.nio.charset.UnsupportedCharsetException - if the character set declared in the message is not supported on this platformpublic boolean isText()
BrowserUpHttpUtil.hasTextualContent(String).