Class HttpClientFilter
- java.lang.Object
-
- org.glassfish.grizzly.filterchain.BaseFilter
-
- org.glassfish.grizzly.http.HttpBaseFilter
-
- org.glassfish.grizzly.http.HttpCodecFilter
-
- org.glassfish.grizzly.http.HttpClientFilter
-
- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter,org.glassfish.grizzly.monitoring.MonitoringAware<HttpProbe>
public class HttpClientFilter extends HttpCodecFilter
Client sideHttpCodecFilterimplementation, which is responsible for decodingHttpResponsePacketand encodingHttpRequestPacketmessages. This Filter is usually used, when we build an asynchronous HTTP client connection.- Author:
- Alexey Stashok
- See Also:
HttpCodecFilter,HttpServerFilter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.glassfish.grizzly.http.HttpCodecFilter
HttpCodecFilter.ContentParsingState, HttpCodecFilter.HeaderParsingState
-
-
Field Summary
-
Fields inherited from class org.glassfish.grizzly.http.HttpCodecFilter
chunkingEnabled, CLOSE_BYTES, contentEncodings, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE, KEEPALIVE_BYTES, maxHeadersSize, maxPayloadRemainderToSkip, monitoringConfig, preserveHeaderCase
-
-
Constructor Summary
Constructors Constructor Description HttpClientFilter()Constructor, which creates HttpClientFilter instanceHttpClientFilter(int maxHeadersSize)Constructor, which creates HttpClientFilter instance, with the specific secure and max header size parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclearResponse(org.glassfish.grizzly.Connection connection)protected org.glassfish.grizzly.BufferencodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpPacket input)org.glassfish.grizzly.filterchain.NextActionhandleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event)org.glassfish.grizzly.filterchain.NextActionhandleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)The method is called, once we have received aBuffer, which has to be transformed into HTTP response packet part.org.glassfish.grizzly.filterchain.NextActionhandleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx)The method is called, once we need to serialize aHttpPacket, which may represent HTTP packet header, content or content chunk.protected voidonHttpContentEncoded(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.protected voidonHttpContentError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t)Callback which is invoked when parsing an HTTP message payload fails.protected voidonHttpContentParsed(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked as request/response body content has been processed by thisFilter.protected voidonHttpHeaderError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t)Callback which is invoked when parsing an HTTP message header fails.protected booleanonHttpHeaderParsed(HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Callback invoked when the HTTP message header parsing is complete.protected voidonHttpHeadersEncoded(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.protected voidonHttpHeadersParsed(HttpHeader httpHeader, MimeHeaders headers, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked when HTTP headers portion comes forHttpHeadermessage.protected booleanonHttpPacketParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Callback method, called whenHttpPacketparsing has been completed.protected voidonInitialLineEncoded(HttpHeader header, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.protected voidonInitialLineParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)Invoked when either the request line or status line has been parsed.-
Methods inherited from class org.glassfish.grizzly.http.HttpCodecFilter
addContentEncoding, addTransferEncoding, createJmxManagementObject, decodeHttpPacket, decodeHttpPacketFromBuffer, decodeHttpPacketFromBytes, encodeHttpPacket, encodeKnownHeaders, encodeMimeHeader, encodeMimeHeaders, getContentEncodings, getMaxPayloadRemainderToSkip, getMonitoringConfig, getTransferEncodings, handleRead, isChunkingEnabled, isPreserveHeaderCase, isRemoveHandledContentEncodingHeaders, isSecure, onIncomingUpgrade, onOutgoingUpgrade, parseHeaderFromBuffer, parseHeaderFromBytes, parseHeaderName, parseHeaderName, parseHeadersFromBuffer, parseHeadersFromBytes, parseHeaderValue, parseHeaderValue, removeContentEncoding, removeTransferEncoding, setMaxPayloadRemainderToSkip, setPreserveHeaderCase, setRemoveHandledContentEncodingHeaders, statusDropsConnection
-
Methods inherited from class org.glassfish.grizzly.http.HttpBaseFilter
bind
-
-
-
-
Constructor Detail
-
HttpClientFilter
public HttpClientFilter()
Constructor, which creates HttpClientFilter instance
-
HttpClientFilter
public HttpClientFilter(int maxHeadersSize)
Constructor, which creates HttpClientFilter instance, with the specific secure and max header size parameter.- Parameters:
maxHeadersSize- the maximum size of the HTTP message header.
-
-
Method Detail
-
handleWrite
public org.glassfish.grizzly.filterchain.NextAction handleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOExceptionDescription copied from class:HttpCodecFilterThe method is called, once we need to serialize aHttpPacket, which may represent HTTP packet header, content or content chunk. Filter getsHttpPacket, which represents a HTTP header, content, or content part. As the result of "write" transformation - we will getBuffer, which will represent serialized HTTP packet.- Specified by:
handleWritein interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleWritein classHttpCodecFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-
handleRead
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOExceptionThe method is called, once we have received aBuffer, which has to be transformed into HTTP response packet part. Filter getsBuffer, which represents a part or complete HTTP response message. As the result of "read" transformation - we will getHttpContentmessage, which will represent HTTP response packet content (might be zero length content) and reference to aHttpHeader, which contains HTTP response message header.- Specified by:
handleReadin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleReadin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-
handleEvent
public org.glassfish.grizzly.filterchain.NextAction handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event) throws IOException- Specified by:
handleEventin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleEventin classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
onHttpPacketParsed
protected boolean onHttpPacketParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterCallback method, called whenHttpPacketparsing has been completed.- Specified by:
onHttpPacketParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.s
-
onHttpHeaderParsed
protected boolean onHttpHeaderParsed(HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterCallback invoked when the HTTP message header parsing is complete.- Specified by:
onHttpHeaderParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerbuffer-Bufferthe header was parsed fromctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.
-
onHttpHeaderError
protected void onHttpHeaderError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException
Description copied from class:HttpCodecFilterCallback which is invoked when parsing an HTTP message header fails. The processing logic has to take care about error handling and following connection closing.
- Specified by:
onHttpHeaderErrorin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException
-
onHttpContentError
protected void onHttpContentError(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException
Description copied from class:HttpCodecFilterCallback which is invoked when parsing an HTTP message payload fails. The processing logic has to take care about error handling and following connection closing.
- Specified by:
onHttpContentErrorin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException
-
onInitialLineParsed
protected void onInitialLineParsed(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked when either the request line or status line has been parsed.
- Specified by:
onInitialLineParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onInitialLineEncoded
protected void onInitialLineEncoded(HttpHeader header, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onInitialLineEncodedin classHttpCodecFilter- Parameters:
header-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onHttpHeadersParsed
protected void onHttpHeadersParsed(HttpHeader httpHeader, MimeHeaders headers, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked when HTTP headers portion comes for
HttpHeadermessage. Depending on the transfer encoding being used by the current request, this method may be invoked multiple times.- Specified by:
onHttpHeadersParsedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerheaders- the headers portion, that has been parsedctx- processing context.
-
onHttpHeadersEncoded
protected void onHttpHeadersEncoded(HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onHttpHeadersEncodedin classHttpCodecFilter- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.
-
onHttpContentParsed
protected void onHttpContentParsed(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked as request/response body content has been processed by this
Filter.- Specified by:
onHttpContentParsedin classHttpCodecFilter- Parameters:
content- request/response body contentctx- processing context.
-
onHttpContentEncoded
protected void onHttpContentEncoded(HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
Description copied from class:HttpCodecFilterInvoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.
- Specified by:
onHttpContentEncodedin classHttpCodecFilter- Parameters:
content-HttpContent, which represents HTTP packet headerctx- processing context.
-
clearResponse
protected final void clearResponse(org.glassfish.grizzly.Connection connection)
-
encodeHttpPacket
protected org.glassfish.grizzly.Buffer encodeHttpPacket(org.glassfish.grizzly.filterchain.FilterChainContext ctx, HttpPacket input)- Overrides:
encodeHttpPacketin classHttpCodecFilter
-
-