public class HmuxRequest extends AbstractHttpRequest implements ProtocolConnection
Packets are straightforward:
code l2 l1 l0 contentsWhere code is the code of the packet and l2-0 give 12 bits of length.
The protocol is designed to allow pipelining and buffering whenever possible. So most commands are not acked. Data from the frontend (POST) does need acks to prevent deadlocks at either end while waiting for new data.
The overriding protocol is controlled by requests from the frontend server.
A ping request:
Frontend Backend
CSE_PING
CSE_END
CSE_END
A GET request:
Frontend Backend
CSE_METHOD
...
CSE_HEADER/CSE_VALUE
CSE_END
CSE_DATA
CSE_DATA
CSE_END
Short POST:
Frontend Backend
CSE_METHOD
...
CSE_HEADER/CSE_VALUE
CSE_DATA
CSE_END
CSE_DATA
CSE_DATA
CSE_END
Long POST:
Frontend Backend
CSE_METHOD
...
CSE_HEADER/CSE_VALUE
CSE_DATA
CSE_DATA (optional)
CSE_DATA
CSE_ACK
CSE_DATA (optional)
CSE_DATA
CSE_ACK
CSE_END
CSE_DATA
CSE_END
| Modifier and Type | Class and Description |
|---|---|
static class |
HmuxRequest.ProtocolResult |
_headerCodes, JSP_EXCEPTION, SHUTDOWN, TOKEN| Constructor and Description |
|---|
HmuxRequest(ServletService server,
SocketLink conn,
HmuxProtocol protocol) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkLogin() |
HmuxResponse |
createResponse() |
java.lang.String |
dbgId() |
void |
finishRequest()
Cleans up at the end of the request
|
protected void |
flushNext() |
protected boolean |
flushNextBuffer() |
java.lang.String |
getHeader(java.lang.String key)
Returns the header.
|
CharSegment |
getHeaderBuffer(char[] buf,
int length) |
CharSegment |
getHeaderBuffer(java.lang.String key)
Fills the result with the header values as
CharSegment values.
|
void |
getHeaderBuffers(java.lang.String key,
java.util.ArrayList<CharSegment> values)
Fills the result with a list of the header values as
CharSegment values.
|
java.util.Enumeration<java.lang.String> |
getHeaderNames()
Enumerates the header keys
|
protected CharBuffer |
getHost()
Returns a char buffer containing the host.
|
java.lang.String |
getMethod()
Returns the header.
|
CharSegment |
getMethodBuffer() |
protected byte[] |
getNextBuffer() |
protected int |
getNextBufferOffset() |
protected int |
getNextStartOffset() |
java.lang.String |
getProtocol()
Returns the protocol.
|
CharSegment |
getProtocolBuffer() |
java.lang.String |
getRemoteAddr() |
void |
getRemoteAddr(CharBuffer cb) |
java.lang.String |
getRemoteHost() |
protected java.lang.String |
getRequestId() |
java.lang.String |
getRequestURI()
Returns the URI for the request, special casing the IIS issues.
|
java.lang.String |
getServerName()
Returns the server name.
|
int |
getServerPort()
Returns the server's port.
|
byte[] |
getUriBuffer() |
int |
getUriLength() |
protected void |
handleConnectionClose()
Called for a connection: close
|
boolean |
handleRequest()
Handles a new connection.
|
boolean |
hasRequest()
Returns true if a valid HTTP request has started.
|
boolean |
initStream(ReadStream readStream,
ReadStream rawStream)
Initialize the read stream from the raw stream.
|
boolean |
isSecure()
Returns true if the request is secure.
|
boolean |
isSuspend() |
boolean |
isWaitForRead()
Return true if the connection should wait for a read before
handling the request.
|
void |
onCloseConnection()
Close when the socket closes.
|
void |
onStartConnection()
Called when the connection starts
|
int |
printRemoteAddr(byte[] buffer,
int offset) |
void |
setHeader(java.lang.String key,
java.lang.String value)
Sets the header.
|
protected void |
setNextBufferOffset(int offset) |
protected void |
startRequest()
Clears variables at the start of a new request.
|
java.lang.String |
toString() |
protected byte[] |
writeNextBuffer(int offset) |
protected void |
writeTail() |
addHeaderInt, allocateHttpBufferStore, buildInvocation, cleanup, clearRequest, clientDisconnect, findSessionIdFromConnection, finishInvocation, getAbstractHttpResponse, getAvailable, getBufferAvailable, getCharacterEncoding, getCharBuffer, getConnection, getConnectionId, getContentLength, getContentType, getContentTypeBuffer, getCookies, getDateHeader, getErrorManager, getForm, getFormParser, getForwardedHostHeader, getHeaderKey, getHeaders, getHeaderSize, getHeaderValue, getHostHeader, getHttpBufferStore, getInputStream, getIntHeader, getInvocation, getInvocationServer, getLocale, getLocales, getLocalHost, getLocalPort, getLongContentLength, getProtocolRequestURL, getRawInput, getRawRead, getRawReadBuffer, getRawWrite, getReader, getReadStream, getRemotePort, getRequestFacade, getRequestURL, getResponse, getResponseFacade, getScheme, getServer, getSmallHeaderBuffer, getSmallHeaderKeys, getSmallHeaderValues, getSmallUriBuffer, getStartTime, getStream, getStream, getTcpSocketLink, getUserPrincipal, getWebApp, handleResume, init, initAttributes, isCometActive, isConnectionClosed, isDuplex, isIgnoreClientDisconnect, isKeepalive, isTransportSecure, isUserInRole, killKeepalive, onAttachThread, onDetachThread, restartServer, runAs, sendRequestError, setCharacterEncoding, setContentLength, shutdown, skip, startDuplex, startInvocationclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetProtocolRequestURL, handleResume, init, onAttachThread, onDetachThreadpublic static final int HMUX_CHANNEL
public static final int HMUX_ACK
public static final int HMUX_ERROR
public static final int HMUX_YIELD
public static final int HMUX_QUIT
public static final int HMUX_EXIT
public static final int HMUX_DATA
public static final int HMUX_URI
public static final int HMUX_STRING
public static final int HMUX_HEADER
public static final int HMUX_BINARY
public static final int HMUX_PROTOCOL
public static final int HMUX_META_HEADER
public static final int CSE_NULL
public static final int CSE_PATH_INFO
public static final int CSE_PROTOCOL
public static final int CSE_REMOTE_USER
public static final int CSE_QUERY_STRING
public static final int HMUX_FLUSH
public static final int CSE_SERVER_PORT
public static final int CSE_REMOTE_HOST
public static final int CSE_REMOTE_ADDR
public static final int CSE_REMOTE_PORT
public static final int CSE_REAL_PATH
public static final int CSE_SCRIPT_FILENAME
public static final int HMUX_METHOD
public static final int CSE_AUTH_TYPE
public static final int CSE_URI
public static final int CSE_CONTENT_LENGTH
public static final int CSE_CONTENT_TYPE
public static final int CSE_IS_SECURE
public static final int HMUX_STATUS
public static final int CSE_CLIENT_CERT
public static final int CSE_SERVER_TYPE
public static final int HMUX_SERVER_NAME
public static final int CSE_SEND_HEADER
public static final int CSE_FLUSH
public static final int CSE_KEEPALIVE
public static final int CSE_END
public static final int CSE_QUERY
public static final int HMUX_TO_UNIDIR_HMTP
public static final int HMUX_SWITCH_TO_HMTP
public static final int HMUX_HMTP_OK
public static final int HMUX_DISPATCH_PROTOCOL
public static final int HMUX_JMS_PROTOCOL
public static final int HMUX_HTTP_PROXY_PROTOCOL
public HmuxRequest(ServletService server, SocketLink conn, HmuxProtocol protocol)
public HmuxResponse createResponse()
createResponse in class AbstractHttpRequestpublic boolean isWaitForRead()
ProtocolConnectionisWaitForRead in interface ProtocolConnectionpublic boolean hasRequest()
hasRequest in class AbstractHttpRequestpublic boolean isSuspend()
isSuspend in class AbstractHttpRequestpublic boolean handleRequest()
throws java.io.IOException
AbstractProtocolConnectionhandleRequest in interface ProtocolConnectionhandleRequest in class AbstractProtocolConnectionjava.io.IOExceptionpublic boolean initStream(ReadStream readStream, ReadStream rawStream) throws java.io.IOException
initStream in class AbstractHttpRequestjava.io.IOExceptionprotected boolean checkLogin()
public void onStartConnection()
AbstractHttpRequestonStartConnection in interface ProtocolConnectiononStartConnection in class AbstractHttpRequestprotected void startRequest()
throws java.io.IOException
startRequest in class AbstractHttpRequestjava.io.IOExceptionpublic java.lang.String getMethod()
getMethod in class AbstractHttpRequestpublic CharSegment getMethodBuffer()
protected CharBuffer getHost()
getHost in class AbstractHttpRequestpublic final byte[] getUriBuffer()
getUriBuffer in class AbstractHttpRequestpublic final int getUriLength()
getUriLength in class AbstractHttpRequestpublic java.lang.String getProtocol()
getProtocol in class AbstractHttpRequestpublic CharSegment getProtocolBuffer()
public boolean isSecure()
isSecure in class AbstractHttpRequestpublic java.lang.String getHeader(java.lang.String key)
getHeader in class AbstractHttpRequestkey - the header keypublic CharSegment getHeaderBuffer(java.lang.String key)
AbstractHttpRequestgetHeaderBuffer in class AbstractHttpRequestkey - the header namepublic CharSegment getHeaderBuffer(char[] buf, int length)
public void setHeader(java.lang.String key,
java.lang.String value)
AbstractHttpRequestsetHeader in class AbstractHttpRequestpublic void getHeaderBuffers(java.lang.String key,
java.util.ArrayList<CharSegment> values)
AbstractHttpRequestgetHeaderBuffers in class AbstractHttpRequestkey - the header namevalues - the resulting bufferpublic java.util.Enumeration<java.lang.String> getHeaderNames()
AbstractHttpRequestgetHeaderNames in class AbstractHttpRequestpublic java.lang.String getRequestURI()
getRequestURI in class AbstractHttpRequestpublic java.lang.String getServerName()
getServerName in class AbstractHttpRequestpublic int getServerPort()
AbstractHttpRequestgetServerPort in class AbstractHttpRequestpublic java.lang.String getRemoteAddr()
getRemoteAddr in class AbstractHttpRequestpublic void getRemoteAddr(CharBuffer cb)
public int printRemoteAddr(byte[] buffer,
int offset)
throws java.io.IOException
printRemoteAddr in class AbstractHttpRequestjava.io.IOExceptionpublic java.lang.String getRemoteHost()
getRemoteHost in class AbstractHttpRequestprotected void handleConnectionClose()
handleConnectionClose in class AbstractHttpRequestpublic void finishRequest()
throws java.io.IOException
AbstractHttpRequestfinishRequest in class AbstractHttpRequestjava.io.IOExceptionprotected byte[] getNextBuffer()
protected int getNextStartOffset()
protected int getNextBufferOffset()
throws java.io.IOException
java.io.IOExceptionprotected void setNextBufferOffset(int offset)
throws java.io.IOException
java.io.IOExceptionprotected byte[] writeNextBuffer(int offset)
throws java.io.IOException
java.io.IOExceptionprotected void flushNext()
throws java.io.IOException
java.io.IOExceptionprotected final boolean flushNextBuffer()
throws java.io.IOException
java.io.IOExceptionprotected void writeTail()
throws java.io.IOException
java.io.IOExceptionpublic void onCloseConnection()
onCloseConnection in interface ProtocolConnectiononCloseConnection in class AbstractHttpRequestprotected java.lang.String getRequestId()
public final java.lang.String dbgId()
dbgId in class AbstractHttpRequestpublic java.lang.String toString()
toString in class java.lang.Object