|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object anon.proxy.HTTPProxyCallback
public class HTTPProxyCallback
Provides functionality for parsing and storing the headers of a HTTP-Connection. Invoked by the ProxyCallbackHandler framework. HTTPConnectionListeners can be registered to examine and modify the corresponding HTTP messages before they are transmitted further. Also Listeners can be notified about how much payload was transmitted via the corresponding HTTPConnection.
Nested Class Summary | |
---|---|
class |
HTTPProxyCallback.HTTPConnectionHeader
|
private static interface |
HTTPProxyCallback.IHTTPHelper
|
Field Summary | |
---|---|
(package private) static java.lang.String |
CRLF
|
private static HTTPProxyCallback.IHTTPHelper |
DOWNSTREAM_HELPER
|
private static boolean |
FIRE_EVENT
|
static java.lang.String |
HTTP_ACCEPT
|
static java.lang.String |
HTTP_ACCEPT_CHARSET
|
static java.lang.String |
HTTP_ACCEPT_ENCODING
|
static java.lang.String |
HTTP_ACCEPT_LANGUAGE
|
static java.lang.String |
HTTP_CACHE_CONTROL
|
static java.lang.String |
HTTP_CONNECTION
|
static java.lang.String |
HTTP_CONTENT_ENCODING
|
static java.lang.String |
HTTP_CONTENT_LENGTH
|
(package private) static java.lang.String |
HTTP_HEADER_DELIM
|
(package private) static java.lang.String |
HTTP_HEADER_END
|
(package private) static byte[] |
HTTP_HEADER_END_BYTES
|
static java.lang.String |
HTTP_HOST
|
static java.lang.String |
HTTP_IE_UA_CPU
|
static java.lang.String |
HTTP_KEEP_ALIVE
|
static java.lang.String |
HTTP_PRAGMA
|
static java.lang.String |
HTTP_PROXY_CONNECTION
|
static java.lang.String |
HTTP_RANGE
|
static java.lang.String |
HTTP_REFERER
|
(package private) static java.lang.String[] |
HTTP_REQUEST_METHODS
|
(package private) static byte[][] |
HTTP_REQUEST_METHODS_BYTES
|
(package private) static java.lang.String |
HTTP_START_LINE_KEY
|
static java.lang.String |
HTTP_USER_AGENT
|
(package private) static java.lang.String |
HTTP_VERSION_PREFIX
|
(package private) static byte[] |
HTTP_VERSION_PREFIX_BYTES
|
private java.util.Hashtable |
m_connectionHTTPHeaders
Container for the Headers of a whole HTTP Connection including Request and Response. |
private java.util.Hashtable |
m_downstreamBytes
|
private java.util.Vector |
m_httpConnectionListeners
|
private java.util.Hashtable |
m_unfinishedRequests
request messages whose parsing hasn't finished yet |
private java.util.Hashtable |
m_unfinishedResponses
response messages whose parsing hasn't finished yet |
private java.util.Hashtable |
m_upstreamBytes
|
(package private) static int |
MESSAGE_TYPE_REQUEST
|
(package private) static int |
MESSAGE_TYPE_RESPONSE
|
(package private) static java.lang.String |
MSG_INVALID_LINETERM_REQUEST
|
(package private) static java.lang.String |
MSG_INVALID_LINETERM_RESPONSE
|
private static HTTPProxyCallback.IHTTPHelper |
UPSTREAM_HELPER
|
Fields inherited from interface anon.proxy.ProxyCallback |
---|
STATUS_DELAY, STATUS_FINISHED, STATUS_PROCESSABLE |
Constructor Summary | |
---|---|
HTTPProxyCallback()
|
Method Summary | |
---|---|
void |
addHTTPConnectionListener(AbstractHTTPConnectionListener listener)
|
static boolean |
checkValidity(java.lang.String headerData)
checks whether the HTTP message headers fragment specified by headerData contains invalid line terminations, i.e. |
void |
closeRequest(AnonProxyRequest anonRequest)
|
private long |
countContentBytes(AnonProxyRequest anonRequest,
int contentBytes,
java.util.Hashtable contentBytesCount,
boolean fire)
|
private boolean |
extractHeaderParts(AnonProxyRequest anonRequest,
java.lang.String chunkData,
int messageType)
|
void |
fireDownstreamContentBytesReceived(HTTPConnectionEvent event)
|
void |
fireRequestHeadersReceived(HTTPConnectionEvent event)
|
void |
fireResponseHeadersReceived(HTTPConnectionEvent event)
|
void |
fireUpstreamContentBytesReceived(HTTPConnectionEvent event)
|
private long |
getContentBytes(AnonProxyRequest anonRequest,
java.util.Hashtable contentByteCount)
|
long |
getDownStreamContentBytes(AnonProxyRequest anonRequest)
|
private HTTPConnectionEvent |
getEvent(AnonProxyRequest anonRequest)
|
long |
getUpStreamContentBytes(AnonProxyRequest anonRequest)
|
int |
handleDownstreamChunk(AnonProxyRequest anonRequest,
ProxyCallbackBuffer buffer)
|
private int |
handleStreamChunk(AnonProxyRequest anonRequest,
ProxyCallbackBuffer buffer,
int a_messageType,
HTTPProxyCallback.IHTTPHelper a_helper)
|
int |
handleUpstreamChunk(AnonProxyRequest anonRequest,
ProxyCallbackBuffer buffer)
|
private boolean |
hasAlignedHTTPStartLine(byte[] chunk,
int off,
int len,
int messageType)
|
private boolean |
hasAlignedHTTPStartLine(java.lang.String chunkData,
int messageType)
|
static int |
indexOfHTTPHeaderEnd(byte[] prefix,
byte[] chunk,
int chunkStartIndex,
int chunkEndIndex)
Returns the index of the first char after the first occurence of the CRLFCRLF termination in the array 'chunk' or -1 if such a termination sequence was not found. |
static int |
indexOfHTTPHeaderEnd(byte[] chunk,
int startIndex,
int endIndex)
Returns the index of the first char after the first occurence of the CRLFCRLF termination in the array 'chunk' or -1 if such a termination sequence was not found. |
private boolean |
isRequest(byte[] chunk,
int off,
int len)
this method makes a bytewise comparison so we don't have to turn the whole chunk into a string for header detection. |
private boolean |
isRequest(java.lang.String chunkData)
|
private boolean |
isResponse(byte[] chunk,
int off,
int len)
|
private boolean |
isResponse(java.lang.String chunkData)
|
private void |
parseHTTPHeader(java.lang.String headerData,
HTTPProxyCallback.HTTPConnectionHeader connHeader,
int headerType)
|
void |
removeAllHTTPConnectionListeners()
|
void |
removeHTTPConnectionListener(AbstractHTTPConnectionListener listener)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean FIRE_EVENT
static final int MESSAGE_TYPE_REQUEST
static final int MESSAGE_TYPE_RESPONSE
static final java.lang.String CRLF
static final java.lang.String HTTP_HEADER_END
static final byte[] HTTP_HEADER_END_BYTES
static final java.lang.String HTTP_HEADER_DELIM
static final java.lang.String HTTP_START_LINE_KEY
static final java.lang.String HTTP_VERSION_PREFIX
static final byte[] HTTP_VERSION_PREFIX_BYTES
static final java.lang.String[] HTTP_REQUEST_METHODS
static final byte[][] HTTP_REQUEST_METHODS_BYTES
static final java.lang.String MSG_INVALID_LINETERM_REQUEST
static final java.lang.String MSG_INVALID_LINETERM_RESPONSE
public static final java.lang.String HTTP_CONTENT_LENGTH
public static final java.lang.String HTTP_CONTENT_ENCODING
public static final java.lang.String HTTP_HOST
public static final java.lang.String HTTP_USER_AGENT
public static final java.lang.String HTTP_ACCEPT
public static final java.lang.String HTTP_ACCEPT_LANGUAGE
public static final java.lang.String HTTP_ACCEPT_ENCODING
public static final java.lang.String HTTP_ACCEPT_CHARSET
public static final java.lang.String HTTP_KEEP_ALIVE
public static final java.lang.String HTTP_PROXY_CONNECTION
public static final java.lang.String HTTP_CONNECTION
public static final java.lang.String HTTP_REFERER
public static final java.lang.String HTTP_CACHE_CONTROL
public static final java.lang.String HTTP_PRAGMA
public static final java.lang.String HTTP_RANGE
public static final java.lang.String HTTP_IE_UA_CPU
private java.util.Hashtable m_connectionHTTPHeaders
private java.util.Hashtable m_unfinishedRequests
private java.util.Hashtable m_unfinishedResponses
private java.util.Hashtable m_downstreamBytes
private java.util.Hashtable m_upstreamBytes
private java.util.Vector m_httpConnectionListeners
private static final HTTPProxyCallback.IHTTPHelper UPSTREAM_HELPER
private static final HTTPProxyCallback.IHTTPHelper DOWNSTREAM_HELPER
Constructor Detail |
---|
public HTTPProxyCallback()
Method Detail |
---|
public int handleUpstreamChunk(AnonProxyRequest anonRequest, ProxyCallbackBuffer buffer) throws ProxyCallbackNotProcessableException
handleUpstreamChunk
in interface ProxyCallback
ProxyCallbackNotProcessableException
public int handleDownstreamChunk(AnonProxyRequest anonRequest, ProxyCallbackBuffer buffer) throws ProxyCallbackNotProcessableException
handleDownstreamChunk
in interface ProxyCallback
ProxyCallbackNotProcessableException
private int handleStreamChunk(AnonProxyRequest anonRequest, ProxyCallbackBuffer buffer, int a_messageType, HTTPProxyCallback.IHTTPHelper a_helper) throws ProxyCallbackNotProcessableException
ProxyCallbackNotProcessableException
private long countContentBytes(AnonProxyRequest anonRequest, int contentBytes, java.util.Hashtable contentBytesCount, boolean fire)
public long getUpStreamContentBytes(AnonProxyRequest anonRequest)
public long getDownStreamContentBytes(AnonProxyRequest anonRequest)
private long getContentBytes(AnonProxyRequest anonRequest, java.util.Hashtable contentByteCount)
private HTTPConnectionEvent getEvent(AnonProxyRequest anonRequest)
private boolean extractHeaderParts(AnonProxyRequest anonRequest, java.lang.String chunkData, int messageType) throws ProxyCallbackNotProcessableException
ProxyCallbackNotProcessableException
public static boolean checkValidity(java.lang.String headerData)
headerData
- the fragment of the HTTP headers of a HTTP message
private boolean hasAlignedHTTPStartLine(java.lang.String chunkData, int messageType)
private boolean hasAlignedHTTPStartLine(byte[] chunk, int off, int len, int messageType)
private boolean isRequest(java.lang.String chunkData)
private boolean isRequest(byte[] chunk, int off, int len)
chunk
- len
-
private boolean isResponse(java.lang.String chunkData)
private boolean isResponse(byte[] chunk, int off, int len)
public static int indexOfHTTPHeaderEnd(byte[] chunk, int startIndex, int endIndex)
public static int indexOfHTTPHeaderEnd(byte[] prefix, byte[] chunk, int chunkStartIndex, int chunkEndIndex)
private void parseHTTPHeader(java.lang.String headerData, HTTPProxyCallback.HTTPConnectionHeader connHeader, int headerType)
public void addHTTPConnectionListener(AbstractHTTPConnectionListener listener)
public void removeHTTPConnectionListener(AbstractHTTPConnectionListener listener)
public void removeAllHTTPConnectionListeners()
public void fireRequestHeadersReceived(HTTPConnectionEvent event)
public void fireResponseHeadersReceived(HTTPConnectionEvent event)
public void fireDownstreamContentBytesReceived(HTTPConnectionEvent event)
public void fireUpstreamContentBytesReceived(HTTPConnectionEvent event)
public void closeRequest(AnonProxyRequest anonRequest)
closeRequest
in interface ProxyCallback
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |