public class HttpClientFilter extends HttpCodecFilter
HttpCodecFilter
implementation, which is responsible for
decoding HttpResponsePacket
and encoding HttpRequestPacket
messages.
This Filter is usually used, when we build an asynchronous HTTP client
connection.HttpCodecFilter
,
HttpServerFilter
HttpCodecFilter.ContentParsingState, HttpCodecFilter.HeaderParsingState
chunkingEnabled, contentEncodings, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE, FLUSH_AND_CLOSE_HANDLER, maxHeadersSize, monitoringConfig
Constructor and Description |
---|
HttpClientFilter()
Constructor, which creates HttpClientFilter instance
|
HttpClientFilter(int maxHeadersSize)
Constructor, which creates HttpClientFilter instance,
with the specific secure and max header size parameter.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearResponse(Connection connection) |
protected Buffer |
encodeHttpPacket(FilterChainContext ctx,
HttpPacket input) |
NextAction |
handleRead(FilterChainContext ctx)
The method is called, once we have received a
Buffer ,
which has to be transformed into HTTP response packet part. |
NextAction |
handleWrite(FilterChainContext ctx)
The method is called, once we need to serialize a
HttpPacket ,
which may represent HTTP packet header, content or content chunk. |
protected void |
onHttpContentEncoded(HttpContent content,
FilterChainContext ctx)
Invoked when a HTTP body chunk has been encoded in preparation to being
transmitted to the user-agent.
|
protected void |
onHttpContentError(HttpHeader httpHeader,
FilterChainContext ctx,
Throwable t)
Callback which is invoked when parsing an HTTP message payload fails.
|
protected void |
onHttpContentParsed(HttpContent content,
FilterChainContext ctx)
Invoked as request/response body content has been processed by this
Filter . |
protected void |
onHttpHeaderError(HttpHeader httpHeader,
FilterChainContext ctx,
Throwable t)
Callback which is invoked when parsing an HTTP message header fails.
|
protected boolean |
onHttpHeaderParsed(HttpHeader httpHeader,
Buffer buffer,
FilterChainContext ctx)
Callback invoked when the HTTP message header parsing is complete.
|
protected void |
onHttpHeadersEncoded(HttpHeader httpHeader,
FilterChainContext ctx)
Invoked when HTTP headers have been encoded in preparation to being
transmitted to the user-agent.
|
protected void |
onHttpHeadersParsed(HttpHeader httpHeader,
FilterChainContext ctx)
Invoked when all headers of the packet have been parsed.
|
protected boolean |
onHttpPacketParsed(HttpHeader httpHeader,
FilterChainContext ctx)
Callback method, called when
HttpPacket parsing has been completed. |
protected void |
onInitialLineEncoded(HttpHeader header,
FilterChainContext ctx)
Invoked when the intial response line has been encoded in preparation
to being transmitted to the user-agent.
|
protected void |
onInitialLineParsed(HttpHeader httpHeader,
FilterChainContext ctx)
Invoked when either the request line or status line has been parsed.
|
addContentEncoding, addTransferEncoding, createJmxManagementObject, decodeHttpPacket, decodeHttpPacketFromBuffer, decodeHttpPacketFromBytes, encodeHttpPacket, encodeKnownHeaders, encodeMimeHeader, encodeMimeHeaders, flushAndClose, getContentEncodings, getMonitoringConfig, getTransferEncodings, gracefullyCloseConnection, handleRead, isChunkingEnabled, isSecure, parseHeaderFromBuffer, parseHeaderFromBytes, parseHeaderName, parseHeaderName, parseHeadersFromBuffer, parseHeadersFromBytes, parseHeaderValue, parseHeaderValue, prepareForShutdown, removeContentEncoding, removeTransferEncoding
bind
createContext, exceptionOccurred, handleAccept, handleClose, handleConnect, handleEvent, onAdded, onFilterChainChanged, onRemoved
public HttpClientFilter()
public HttpClientFilter(int maxHeadersSize)
maxHeadersSize
- the maximum size of the HTTP message header.public NextAction handleWrite(FilterChainContext ctx) throws IOException
HttpCodecFilter
HttpPacket
,
which may represent HTTP packet header, content or content chunk.
Filter gets HttpPacket
, which represents a HTTP header, content,
or content part. As the result of "write" transformation - we will get
Buffer
, which will represent serialized HTTP packet.handleWrite
in interface Filter
handleWrite
in class HttpCodecFilter
ctx
- Request processing contextNextAction
IOException
public NextAction handleRead(FilterChainContext ctx) throws IOException
Buffer
,
which has to be transformed into HTTP response packet part.
Filter gets Buffer
, which represents a part or complete HTTP
response message. As the result of "read" transformation - we will get
HttpContent
message, which will represent HTTP response packet
content (might be zero length content) and reference
to a HttpHeader
, which contains HTTP response message header.handleRead
in interface Filter
handleRead
in class BaseFilter
ctx
- Request processing contextNextAction
IOException
protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx)
HttpCodecFilter
HttpPacket
parsing has been completed.onHttpPacketParsed
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents parsed HTTP packet headerctx
- processing context.true
if an error has occurred while processing
the header portion of the HTTP request, otherwise returns
false
.sprotected boolean onHttpHeaderParsed(HttpHeader httpHeader, Buffer buffer, FilterChainContext ctx)
HttpCodecFilter
onHttpHeaderParsed
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents parsed HTTP packet headerbuffer
- Buffer
the header was parsed fromctx
- processing context.true
if an error has occurred while processing
the header portion of the HTTP request, otherwise returns
false
.protected void onHttpHeaderError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) throws IOException
HttpCodecFilter
Callback which is invoked when parsing an HTTP message header fails. The processing logic has to take care about error handling and following connection closing.
onHttpHeaderError
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents HTTP packet headerctx
- the FilterChainContext
processing this requestt
- the cause of the errorIOException
protected void onHttpContentError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) throws IOException
HttpCodecFilter
Callback which is invoked when parsing an HTTP message payload fails. The processing logic has to take care about error handling and following connection closing.
onHttpContentError
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents HTTP packet headerctx
- the FilterChainContext
processing this requestt
- the cause of the errorIOException
protected void onInitialLineParsed(HttpHeader httpHeader, FilterChainContext ctx)
HttpCodecFilter
Invoked when either the request line or status line has been parsed.
onInitialLineParsed
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents HTTP packet headerctx
- processing context.protected void onInitialLineEncoded(HttpHeader header, FilterChainContext ctx)
HttpCodecFilter
Invoked when the intial response line has been encoded in preparation to being transmitted to the user-agent.
onInitialLineEncoded
in class HttpCodecFilter
header
- HttpHeader
, which represents HTTP packet headerctx
- processing context.protected void onHttpHeadersParsed(HttpHeader httpHeader, FilterChainContext ctx)
HttpCodecFilter
Invoked when all headers of the packet have been parsed. Depending on the transfer encoding being used by the current request, this method may be invoked multiple times.
onHttpHeadersParsed
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents HTTP packet headerctx
- processing context.protected void onHttpHeadersEncoded(HttpHeader httpHeader, FilterChainContext ctx)
HttpCodecFilter
Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.
onHttpHeadersEncoded
in class HttpCodecFilter
httpHeader
- HttpHeader
, which represents HTTP packet headerctx
- processing context.protected void onHttpContentParsed(HttpContent content, FilterChainContext ctx)
HttpCodecFilter
Invoked as request/response body content has been processed by this
Filter
.
onHttpContentParsed
in class HttpCodecFilter
content
- request/response body contentctx
- processing context.protected void onHttpContentEncoded(HttpContent content, FilterChainContext ctx)
HttpCodecFilter
Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.
onHttpContentEncoded
in class HttpCodecFilter
content
- HttpContent
, which represents HTTP packet headerctx
- processing context.protected final void clearResponse(Connection connection)
protected Buffer encodeHttpPacket(FilterChainContext ctx, HttpPacket input)
encodeHttpPacket
in class HttpCodecFilter
Copyright © 2014 Oracle Corporation. All rights reserved.