Class AbstractHttpLogicHandler
java.lang.Object
org.apache.mina.proxy.AbstractProxyLogicHandler
org.apache.mina.proxy.handlers.http.AbstractHttpLogicHandler
- All Implemented Interfaces:
ProxyLogicHandler
- Direct Known Subclasses:
HttpSmartProxyHandler
AbstractHttpLogicHandler.java - Base class for HTTP proxy
AbstractProxyLogicHandler implementations.
Provides HTTP request encoding/response decoding functionality.- Since:
- MINA 2.0.0-M3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe content length of the proxy response.private static final byte[]private static final Stringprivate intContains the limit of the entity body start in theresponseDataIoBuffer.private intContains the position of the entity body start in theresponseDataIoBuffer.private booleanA flag that indicates that this is a HTTP/1.1 response with chunked data.and that some chunks are missing.private static final byte[]private static final org.slf4j.Loggerprivate HttpProxyResponseThe parsed http proxy responseprivate IoBufferTemporary buffer to accumulate the HTTP response from the proxy.private booleanA flag that indicates that some chunks of data are missing to complete the HTTP/1.1 response.private booleanA flag that indicates that chunked data has been read and that we're now reading the footers. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractHttpLogicHandler(ProxyIoSession proxyIoSession) Creates a newAbstractHttpLogicHandler. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpProxyResponsedecodeResponse(String response) Parse a HTTP response from the proxy server.abstract voidhandleResponse(HttpProxyResponse response) Handles a HTTP response from the proxy server.voidmessageReceived(IoFilter.NextFilter nextFilter, IoBuffer buf) Handles incoming data during the handshake process.private voidreconnect(IoFilter.NextFilter nextFilter, HttpProxyRequest request) Method to reconnect to the proxy when it decides not to maintain the connection during handshake.voidwriteRequest(IoFilter.NextFilter nextFilter, HttpProxyRequest request) Calls writeRequest0(NextFilter, HttpProxyRequest) to write the request.private voidwriteRequest0(IoFilter.NextFilter nextFilter, HttpProxyRequest request) Encodes a HTTP request and sends it to the proxy server.Methods inherited from class AbstractProxyLogicHandler
closeSession, closeSession, enqueueWriteRequest, flushPendingWriteRequests, getProxyFilter, getProxyIoSession, getSession, isHandshakeComplete, setHandshakeComplete, writeDataMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ProxyLogicHandler
doHandshake
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DECODER
-
HTTP_DELIMITER
private static final byte[] HTTP_DELIMITER -
CRLF_DELIMITER
private static final byte[] CRLF_DELIMITER -
responseData
Temporary buffer to accumulate the HTTP response from the proxy. -
parsedResponse
The parsed http proxy response -
contentLength
private int contentLengthThe content length of the proxy response. -
hasChunkedData
private boolean hasChunkedDataA flag that indicates that this is a HTTP/1.1 response with chunked data.and that some chunks are missing. -
waitingChunkedData
private boolean waitingChunkedDataA flag that indicates that some chunks of data are missing to complete the HTTP/1.1 response. -
entityBodyStartPosition
private int entityBodyStartPositionContains the position of the entity body start in theresponseDataIoBuffer. -
entityBodyLimitPosition
private int entityBodyLimitPositionContains the limit of the entity body start in theresponseDataIoBuffer.
-
-
Constructor Details
-
AbstractHttpLogicHandler
Creates a newAbstractHttpLogicHandler.- Parameters:
proxyIoSession- theProxyIoSessionin use.
-
-
Method Details
-
messageReceived
Handles incoming data during the handshake process. Should consume only the handshake data from the buffer, leaving any extra data in place.- Parameters:
nextFilter- the next filterbuf- the buffer holding received data- Throws:
ProxyAuthException- if authentication fails
-
handleResponse
Handles a HTTP response from the proxy server.- Parameters:
response- The response.- Throws:
ProxyAuthException- If we get an error during the proxy authentication
-
writeRequest
Calls writeRequest0(NextFilter, HttpProxyRequest) to write the request. If needed a reconnection to the proxy is done previously.- Parameters:
nextFilter- the next filterrequest- the http request
-
writeRequest0
Encodes a HTTP request and sends it to the proxy server.- Parameters:
nextFilter- the next filterrequest- the http request
-
reconnect
Method to reconnect to the proxy when it decides not to maintain the connection during handshake.- Parameters:
nextFilter- the next filterrequest- the http request
-
decodeResponse
Parse a HTTP response from the proxy server.- Parameters:
response- The response string.- Returns:
- The decoded HttpResponse
- Throws:
Exception- If we get an error while decoding the response
-