Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http

public Class HttpClientFilter

extends HttpCodecFilter
Class Inheritance
Static Imports
org.glassfish.grizzly.http.util.HttpCodecUtils.findEOL, .HttpCodecUtils.findSpace, .HttpCodecUtils.put, .HttpCodecUtils.skipSpaces

Client side 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.
Author
Alexey Stashok
See Also
HttpCodecFilter, HttpServerFilter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Attribute<Queue<HttpRequestPacket>>
private final Attribute<HttpResponsePacket>
Inherited from org.glassfish.grizzly.http.HttpCodecFilter:
chunkingEnabledCLOSE_BYTESCOLON_BYTEScontentEncodingsCRLF_BYTESDEFAULT_MAX_HTTP_PACKET_HEADER_SIZEKEEPALIVE_BYTESmaxHeadersSizemaxPayloadRemainderToSkipmonitoringConfigPRESERVE_HEADER_CASEpreserveHeaderCaseSTRICT_HEADER_NAME_VALIDATION_RFC_9110STRICT_HEADER_VALUE_VALIDATION_RFC_9110

Constructor Summary

AccessConstructor and Description
public
HttpClientFilter()

Constructor, which creates HttpClientFilter instance

public
HttpClientFilter(int
the maximum size of the HTTP message header.
maxHeadersSize
)

Constructor, which creates HttpClientFilter instance, with the specific max header size parameter.

public
HttpClientFilter(final int
the maximum size of the HTTP message header.
maxHeadersSize
,
final Properties
the properties to be used by this filter.
props
)

Constructor, which creates HttpClientFilter instance, with the specific max header size and properties parameter.

Method Summary

Modifier and TypeMethod and Description
private static boolean
protected final void
clearResponse(final Connection<L> connection)

private HttpClientFilter.ClientHttpResponseImpl
pack-priv final boolean
decodeInitialLineFromBuffer(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final Buffer input)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBuffer.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

pack-priv final boolean
decodeInitialLineFromBytes(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final byte[] input, final int end)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBytes.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

protected Buffer
pack-priv Buffer
encodeInitialLine(HttpPacket httpPacket, Buffer output, MemoryManager<E extends Buffer> memoryManager)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.encodeInitialLine.

Method is responsible for serializing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

private Queue<HttpRequestPacket>
public NextAction
public NextAction

Returns:

NextAction
handleRead
(FilterChainContext
Request processing context
ctx
)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

The method is called, once we have received a Buffer, which has to be transformed into HTTP response packet part.

public NextAction
handleWrite(FilterChainContext ctx)

Overrides org.glassfish.grizzly.http.HttpCodecFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

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)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentEncoded.

Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.

protected void
onHttpContentError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentError.

Callback which is invoked when parsing an HTTP message payload fails.

protected void
onHttpContentParsed(HttpContent content, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentParsed.

Invoked as request/response body content has been processed by this org.glassfish.grizzly.filterchain.Filter.

protected void
onHttpHeaderError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderError.

Callback which is invoked when parsing an HTTP message header fails.

protected boolean
onHttpHeaderParsed(final HttpHeader httpHeader, final Buffer buffer, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderParsed.

Callback invoked when the HTTP message header parsing is complete.

protected void
onHttpHeadersEncoded(HttpHeader httpHeader, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersEncoded.

Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.

protected void
onHttpHeadersParsed(final HttpHeader httpHeader, final MimeHeaders headers, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersParsed.

Invoked when HTTP headers portion comes for HttpHeader message.

protected boolean
onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpPacketParsed.

Callback method, called when HttpPacket parsing has been completed.

protected void
onInitialLineEncoded(HttpHeader header, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineEncoded.

Invoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.

protected void
onInitialLineParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineParsed.

Invoked when either the request line or status line has been parsed.

private static void
Inherited from org.glassfish.grizzly.http.HttpCodecFilter:
addContentEncodingaddTransferEncodingcreateJmxManagementObjectdecodeContentdecodeHttpPacketdecodeHttpPacketFromBufferdecodeHttpPacketFromBytesencodeContentencodeHttpPacketencodeInitialLineencodeKnownHeadersencodeMimeHeaderencodeMimeHeadersencodeMimeHeadersgetContentEncodingsgetMaxPayloadRemainderToSkipgetMonitoringConfiggetTransferEncodingshandleReadisChunkingEnabledisPreserveHeaderCaseisRemoveHandledContentEncodingHeadersisSecureonIncomingUpgradeonOutgoingUpgradeparseHeaderFromBufferparseHeaderFromBytesparseHeaderNameparseHeaderNameparseHeadersFromBufferparseHeadersFromBytesparseHeaderValueparseHeaderValueremoveContentEncodingremoveTransferEncodingsetContentEncodingsOnParsingsetContentEncodingsOnSerializingsetMaxPayloadRemainderToSkipsetPreserveHeaderCasesetRemoveHandledContentEncodingHeaderssetTransferEncodingOnParsingsetTransferEncodingOnSerializingstatusDropsConnection

Field Detail

httpRequestQueueAttrback to summary
private final Attribute<Queue<HttpRequestPacket>> httpRequestQueueAttr
httpResponseInProcessAttrback to summary
private final Attribute<HttpResponsePacket> httpResponseInProcessAttr

Constructor Detail

HttpClientFilterback to summary
public HttpClientFilter()

Constructor, which creates HttpClientFilter instance

HttpClientFilterback to summary
public HttpClientFilter(int maxHeadersSize)

Constructor, which creates HttpClientFilter instance, with the specific max header size parameter.

Parameters
maxHeadersSize:int

the maximum size of the HTTP message header.

HttpClientFilterback to summary
public HttpClientFilter(final int maxHeadersSize, final Properties props)

Constructor, which creates HttpClientFilter instance, with the specific max header size and properties parameter.

Parameters
maxHeadersSize:int

the maximum size of the HTTP message header.

props:Properties

the properties to be used by this filter.

Method Detail

checkKeepAliveback to summary
private static boolean checkKeepAlive(final HttpResponsePacket response)
clearResponseback to summary
protected final void clearResponse(final Connection<L> connection)
createHttpResponseback to summary
private HttpClientFilter.ClientHttpResponseImpl createHttpResponse(FilterChainContext ctx)
decodeInitialLineFromBufferback to summary
pack-priv final boolean decodeInitialLineFromBuffer(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final Buffer input)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBuffer.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBuffer.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

Annotations
@Override
decodeInitialLineFromBytesback to summary
pack-priv final boolean decodeInitialLineFromBytes(final FilterChainContext ctx, final HttpPacketParsing httpPacket, final HttpCodecFilter.HeaderParsingState parsingState, final byte[] input, final int end)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBytes.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.decodeInitialLineFromBytes.

Method is responsible for parsing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

Annotations
@Override
encodeHttpPacketback to summary
protected Buffer encodeHttpPacket(final FilterChainContext ctx, final HttpPacket input)

Overrides org.glassfish.grizzly.http.HttpCodecFilter.encodeHttpPacket.

Annotations
@Override
encodeInitialLineback to summary
pack-priv Buffer encodeInitialLine(HttpPacket httpPacket, Buffer output, MemoryManager<E extends Buffer> memoryManager)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.encodeInitialLine.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.encodeInitialLine.

Method is responsible for serializing initial line of HTTP message (different for HttpRequestPacket and HttpResponsePacket).

Annotations
@Override
getRequestQueueback to summary
private Queue<HttpRequestPacket> getRequestQueue(final Connection<L> c)
handleEventback to summary
public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Implements org.glassfish.grizzly.filterchain.Filter.handleEvent.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Handle custom event associated with the Connection. This Filter may either complete the required processing and return StopAction, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning InvokeAction.

Annotations
@Override
handleReadback to summary
public NextAction handleRead(FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

The method is called, once we have received a 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.

Parameters
ctx:FilterChainContext

Request processing context

Returns:NextAction

NextAction

Annotations
@Override
handleWriteback to summary
public NextAction handleWrite(FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.http.HttpCodecFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.handleWrite.

The method is called, once we need to serialize a 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.

Annotations
@Override
onHttpContentEncodedback to summary
protected void onHttpContentEncoded(HttpContent content, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentEncoded.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentEncoded.

Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.

Annotations
@Override
onHttpContentErrorback to summary
protected void onHttpContentError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t) throws IOException

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentError.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentError.

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.

Annotations
@Override
onHttpContentParsedback to summary
protected void onHttpContentParsed(HttpContent content, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentParsed.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpContentParsed.

Invoked as request/response body content has been processed by this org.glassfish.grizzly.filterchain.Filter.

Annotations
@Override
onHttpHeaderErrorback to summary
protected void onHttpHeaderError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t) throws IOException

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderError.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderError.

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.

Annotations
@Override
onHttpHeaderParsedback to summary
protected boolean onHttpHeaderParsed(final HttpHeader httpHeader, final Buffer buffer, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderParsed.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeaderParsed.

Callback invoked when the HTTP message header parsing is complete.

Annotations
@Override
onHttpHeadersEncodedback to summary
protected void onHttpHeadersEncoded(HttpHeader httpHeader, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersEncoded.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersEncoded.

Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.

Annotations
@Override
onHttpHeadersParsedback to summary
protected void onHttpHeadersParsed(final HttpHeader httpHeader, final MimeHeaders headers, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersParsed.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpHeadersParsed.

Invoked when HTTP headers portion comes for HttpHeader message. Depending on the transfer encoding being used by the current request, this method may be invoked multiple times.

Annotations
@Override
onHttpPacketParsedback to summary
protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onHttpPacketParsed.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onHttpPacketParsed.

Callback method, called when HttpPacket parsing has been completed.

Annotations
@Override
onInitialLineEncodedback to summary
protected void onInitialLineEncoded(HttpHeader header, FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineEncoded.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineEncoded.

Invoked when the initial response line has been encoded in preparation to being transmitted to the user-agent.

Annotations
@Override
onInitialLineParsedback to summary
protected void onInitialLineParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

Implements abstract org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineParsed.

Doc from org.glassfish.grizzly.http.HttpCodecFilter.onInitialLineParsed.

Invoked when either the request line or status line has been parsed.

Annotations
@Override
prepareRequestback to summary
private static void prepareRequest(final HttpRequestPacket request)
org.glassfish.grizzly.http back to summary

private final Class HttpClientFilter.ClientHttpResponseImpl

extends HttpResponsePacket
implements HttpPacketParsing
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.HttpPacketParsing

Field Summary

Modifier and TypeField and Description
private static final ThreadCache.CachedTypeIndex<HttpClientFilter.ClientHttpResponseImpl>
private final HttpCodecFilter.ContentParsingState
private boolean
contentTypeParsed

content type parsed flag.

private final HttpCodecFilter.HeaderParsingState
private boolean
Inherited from org.glassfish.grizzly.http.HttpResponsePacket:
httpStatus

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static HttpClientFilter.ClientHttpResponseImpl
public String
public HttpCodecFilter.ContentParsingState
public String
public HttpCodecFilter.HeaderParsingState
protected HttpPacketParsing
public ProcessingState
public void
initialize(final HttpCodecFilter filter, final int initialOffset, final int maxHeaderSize, final int maxNumberOfHeaders)

public boolean
private void
public void
protected void
reset()

Overrides org.glassfish.grizzly.http.HttpResponsePacket.reset.

Reset the internal state.

public void
setCharacterEncoding(final String charset)

Overrides org.glassfish.grizzly.http.HttpHeader.setCharacterEncoding.

Set the character encoding of this HTTP message.

public void
Inherited from org.glassfish.grizzly.http.HttpResponsePacket:
buildergetContentLanguagegetHttpStatusgetInterimStatusgetLocalegetReasonPhrasegetReasonPhraseDCgetReasonPhraseRawDCgetRequestgetStatusinterimResponseSentisAllowCustomReasonPhraseisCustomReasonPhraseSetisHtmlEncodingCustomReasonPhraseisInterimResponseisRequestsetAllowCustomReasonPhrasesetContentLanguagesetContentLengthLongsetHtmlEncodingCustomReasonPhrasesetInterimStatussetLocalesetReasonPhrasesetReasonPhrasesetRequestsetStatussetStatustoString

Field Detail

CACHE_IDXback to summary
private static final ThreadCache.CachedTypeIndex<HttpClientFilter.ClientHttpResponseImpl> CACHE_IDX
contentParsingStateback to summary
private final HttpCodecFilter.ContentParsingState contentParsingState
contentTypeParsedback to summary
private boolean contentTypeParsed

content type parsed flag.

headerParsingStateback to summary
private final HttpCodecFilter.HeaderParsingState headerParsingState
isHeaderParsedback to summary
private boolean isHeaderParsed

Constructor Detail

ClientHttpResponseImplback to summary
private ClientHttpResponseImpl()

Method Detail

createback to summary
public static HttpClientFilter.ClientHttpResponseImpl create()
getCharacterEncodingback to summary
public String getCharacterEncoding()

Overrides org.glassfish.grizzly.http.HttpHeader.getCharacterEncoding.

Annotations
@Override
getContentParsingStateback to summary
public HttpCodecFilter.ContentParsingState getContentParsingState()

Implements org.glassfish.grizzly.http.HttpPacketParsing.getContentParsingState.

Annotations
@Override
getContentTypeback to summary
public String getContentType()

Overrides org.glassfish.grizzly.http.HttpHeader.getContentType.

Annotations
@Override
getHeaderParsingStateback to summary
public HttpCodecFilter.HeaderParsingState getHeaderParsingState()

Implements org.glassfish.grizzly.http.HttpPacketParsing.getHeaderParsingState.

Annotations
@Override
getParsingStateback to summary
protected HttpPacketParsing getParsingState()

Overrides org.glassfish.grizzly.http.HttpHeader.getParsingState.

Annotations
@Override
getProcessingStateback to summary
public ProcessingState getProcessingState()

Implements abstract org.glassfish.grizzly.http.HttpHeader.getProcessingState.

Annotations
@Override
initializeback to summary
public void initialize(final HttpCodecFilter filter, final int initialOffset, final int maxHeaderSize, final int maxNumberOfHeaders)
isHeaderParsedback to summary
public boolean isHeaderParsed()

Implements org.glassfish.grizzly.http.HttpPacketParsing.isHeaderParsed.

Annotations
@Override
parseContentTypeHeaderback to summary
private void parseContentTypeHeader()
recycleback to summary
public void recycle()

Overrides org.glassfish.grizzly.http.HttpHeader.recycle.

Implements org.glassfish.grizzly.Cacheable.recycle.

Annotations
@Override
resetback to summary
protected void reset()

Overrides org.glassfish.grizzly.http.HttpResponsePacket.reset.

Doc from org.glassfish.grizzly.http.HttpResponsePacket.reset.

Reset the internal state.

Annotations
@Override
setCharacterEncodingback to summary
public void setCharacterEncoding(final String charset)

Overrides org.glassfish.grizzly.http.HttpHeader.setCharacterEncoding.

Doc from org.glassfish.grizzly.http.HttpHeader.setCharacterEncoding.

Set the character encoding of this HTTP message.

Annotations
@Override
setHeaderParsedback to summary
public void setHeaderParsed(boolean isHeaderParsed)

Implements org.glassfish.grizzly.http.HttpPacketParsing.setHeaderParsed.

Annotations
@Override