public class HttpObjectUtil extends Object
HttpObject instances, including
HttpMessage and HttpContent.| Constructor and Description |
|---|
HttpObjectUtil() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
extractBinaryHttpEntityBody(io.netty.handler.codec.http.HttpContent httpContent)
Extracts the binary contents from an HTTP message.
|
static String |
extractHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage httpMessage)
Extracts the entity body from a FullHttpMessage, according to the character set in the message's Content-Type header.
|
static String |
extractHttpEntityBody(io.netty.handler.codec.http.HttpContent httpContent,
Charset charset)
Extracts the entity body from an HTTP content object, according to the specified character set.
|
static Charset |
getCharsetFromMessage(io.netty.handler.codec.http.HttpMessage httpMessage)
Derives the charset from the Content-Type header in the HttpMessage.
|
static void |
replaceBinaryHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage message,
byte[] newBinaryContents)
Replaces an HTTP entity body with the specified binary contents.
|
static void |
replaceTextHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage message,
String newContents)
Replaces the entity body of the message with the specified contents.
|
public static void replaceTextHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage message,
String newContents)
BrowserMobHttpUtil.DEFAULT_HTTP_CHARSET if none is specified.
Note: If the charset of the message is not supported on this platform, this will throw an UnsupportedCharsetException.
TODO: Currently this method only works for FullHttpMessages, since it must modify the Content-Length header; determine if this may be applied to chunked messages as wellmessage - the HTTP message to manipulatenewContents - the new entity body contentsUnsupportedCharsetException - if the charset in the message is not supported on this platformpublic static void replaceBinaryHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage message,
byte[] newBinaryContents)
message - the HTTP message to manipulatenewBinaryContents - the new entity body contentspublic static String extractHttpEntityBody(io.netty.handler.codec.http.HttpContent httpContent, Charset charset)
BrowserMobHttpUtil.DEFAULT_HTTP_CHARSET).httpContent - HTTP content object to extract the entity body fromcharset - character set of the entity bodyIllegalArgumentException - if the charset is nullpublic static String extractHttpEntityBody(io.netty.handler.codec.http.FullHttpMessage httpMessage)
BrowserMobHttpUtil.DEFAULT_HTTP_CHARSET).httpMessage - HTTP message to extract entity body fromUnsupportedCharsetException - if there is a charset specified in the content-type header, but it is not supportedpublic static Charset getCharsetFromMessage(io.netty.handler.codec.http.HttpMessage httpMessage) throws UnsupportedCharsetException
BrowserMobHttpUtil.readCharsetInContentTypeHeader(String)
for more details.httpMessage - HTTP message to extract charset fromUnsupportedCharsetException - if there is a charset specified in the content-type header, but it is not supportedpublic static byte[] extractBinaryHttpEntityBody(io.netty.handler.codec.http.HttpContent httpContent)
httpContent - HTTP content object to extract the entity body fromCopyright © 2015. All Rights Reserved.