public class HttpMessageContents extends 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 wellConstructor 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.
|
Charset |
getCharset()
Retrieves the character set of the entity body.
|
String |
getContentType()
Retrieves the Content-Type header of this message.
|
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(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(String newContents)
newContents
- new message contentspublic void setBinaryContents(byte[] newBinaryContents)
newBinaryContents
- new message contentspublic String getTextContents() throws UnsupportedCharsetException
UnsupportedCharsetException
- if the character set declared in the message is not supported on this platformpublic byte[] getBinaryContents()
public String getContentType()
BrowserMobHttpUtil.UNKNOWN_CONTENT_TYPE
).public Charset getCharset() throws UnsupportedCharsetException
UnsupportedCharsetException
.UnsupportedCharsetException
- if the character set declared in the message is not supported on this platformpublic boolean isText()
BrowserMobHttpUtil.hasTextualContent(String)
.Copyright © 2017. All rights reserved.