Package org.apache.mina.http
Class HttpClientDecoder
- java.lang.Object
-
- org.apache.mina.http.HttpClientDecoder
-
- All Implemented Interfaces:
ProtocolDecoder
public class HttpClientDecoder extends java.lang.Object implements ProtocolDecoder
An HTTP decoder
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringBODY_CHUNKEDKey for indicating chunked dataprivate static java.lang.StringBODY_REMAINING_BYTESKey for the number of bytes remaining to read for completing the bodystatic java.util.regex.PatternCOOKIE_SEPARATOR_PATTERNRegex to split cookie header following RFC6265 Section 5.4private static java.lang.StringDECODER_STATE_ATTKey for decoder current statestatic java.util.regex.PatternHEADER_VALUE_PATTERNRegex to parse header name and valuestatic java.util.regex.PatternHEADERS_BODY_PATTERNRegex to parse raw headers from bodystatic java.util.regex.PatternKEY_VALUE_PATTERNRegex to parse out key/value pairsprivate static org.slf4j.LoggerLOGGERstatic java.util.regex.PatternPARAM_STRING_PATTERNRegex to parse out parameters from query stringprivate static java.lang.StringPARTIAL_HEAD_ATTKey for the partial HTTP requests headstatic java.util.regex.PatternQUERY_STRING_PATTERNRegex to parse out QueryString from HttpRequeststatic java.util.regex.PatternRAW_VALUE_PATTERNRegex to parse raw headers and bodystatic java.util.regex.PatternREQUEST_LINE_PATTERNRegex to parse HttpRequest Request Linestatic java.util.regex.PatternRESPONSE_LINE_PATTERNRegex to parse HttpRequest Request Line
-
Constructor Summary
Constructors Constructor Description HttpClientDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecode(IoSession session, IoBuffer msg, ProtocolDecoderOutput out)Decodes binary or protocol-specific content into higher-level message objects.voiddispose(IoSession session)Releases all resources related with this decoder.voidfinishDecode(IoSession session, ProtocolDecoderOutput out)Invoked when the specifiedsessionis closed.private DefaultHttpResponseparseHttpReponseHead(java.nio.ByteBuffer buffer)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
DECODER_STATE_ATT
private static final java.lang.String DECODER_STATE_ATT
Key for decoder current state- See Also:
- Constant Field Values
-
PARTIAL_HEAD_ATT
private static final java.lang.String PARTIAL_HEAD_ATT
Key for the partial HTTP requests head- See Also:
- Constant Field Values
-
BODY_REMAINING_BYTES
private static final java.lang.String BODY_REMAINING_BYTES
Key for the number of bytes remaining to read for completing the body- See Also:
- Constant Field Values
-
BODY_CHUNKED
private static final java.lang.String BODY_CHUNKED
Key for indicating chunked data- See Also:
- Constant Field Values
-
REQUEST_LINE_PATTERN
public static final java.util.regex.Pattern REQUEST_LINE_PATTERN
Regex to parse HttpRequest Request Line
-
RESPONSE_LINE_PATTERN
public static final java.util.regex.Pattern RESPONSE_LINE_PATTERN
Regex to parse HttpRequest Request Line
-
QUERY_STRING_PATTERN
public static final java.util.regex.Pattern QUERY_STRING_PATTERN
Regex to parse out QueryString from HttpRequest
-
PARAM_STRING_PATTERN
public static final java.util.regex.Pattern PARAM_STRING_PATTERN
Regex to parse out parameters from query string
-
KEY_VALUE_PATTERN
public static final java.util.regex.Pattern KEY_VALUE_PATTERN
Regex to parse out key/value pairs
-
RAW_VALUE_PATTERN
public static final java.util.regex.Pattern RAW_VALUE_PATTERN
Regex to parse raw headers and body
-
HEADERS_BODY_PATTERN
public static final java.util.regex.Pattern HEADERS_BODY_PATTERN
Regex to parse raw headers from body
-
HEADER_VALUE_PATTERN
public static final java.util.regex.Pattern HEADER_VALUE_PATTERN
Regex to parse header name and value
-
COOKIE_SEPARATOR_PATTERN
public static final java.util.regex.Pattern COOKIE_SEPARATOR_PATTERN
Regex to split cookie header following RFC6265 Section 5.4
-
-
Method Detail
-
decode
public void decode(IoSession session, IoBuffer msg, ProtocolDecoderOutput out)
Decodes binary or protocol-specific content into higher-level message objects. MINA invokesProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput.- Specified by:
decodein interfaceProtocolDecoder- Parameters:
session- The current Sessionmsg- the buffer to decodeout- TheProtocolDecoderOutputthat will receive the decoded message
-
finishDecode
public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws java.lang.Exception
Invoked when the specifiedsessionis closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response withoutcontent-lengthheader. Implement this method to process the remaining data thatProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)method didn't process completely.- Specified by:
finishDecodein interfaceProtocolDecoder- Parameters:
session- The current Sessionout- TheProtocolDecoderOutputthat contains the decoded message- Throws:
java.lang.Exception- if the read data violated protocol specification
-
dispose
public void dispose(IoSession session) throws java.lang.Exception
Releases all resources related with this decoder.- Specified by:
disposein interfaceProtocolDecoder- Parameters:
session- The current Session- Throws:
java.lang.Exception- if failed to dispose all resources
-
parseHttpReponseHead
private DefaultHttpResponse parseHttpReponseHead(java.nio.ByteBuffer buffer)
-
-