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_ENDA GET request:
Frontend Backend CSE_METHOD ... CSE_HEADER/CSE_VALUE CSE_END CSE_DATA CSE_DATA CSE_ENDShort POST:
Frontend Backend CSE_METHOD ... CSE_HEADER/CSE_VALUE CSE_DATA CSE_END CSE_DATA CSE_DATA CSE_ENDLong 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, startInvocation
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getProtocolRequestURL, handleResume, init, onAttachThread, onDetachThread
public 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 AbstractHttpRequest
public boolean isWaitForRead()
ProtocolConnection
isWaitForRead
in interface ProtocolConnection
public boolean hasRequest()
hasRequest
in class AbstractHttpRequest
public boolean isSuspend()
isSuspend
in class AbstractHttpRequest
public boolean handleRequest() throws java.io.IOException
AbstractProtocolConnection
handleRequest
in interface ProtocolConnection
handleRequest
in class AbstractProtocolConnection
java.io.IOException
public boolean initStream(ReadStream readStream, ReadStream rawStream) throws java.io.IOException
initStream
in class AbstractHttpRequest
java.io.IOException
protected boolean checkLogin()
public void onStartConnection()
AbstractHttpRequest
onStartConnection
in interface ProtocolConnection
onStartConnection
in class AbstractHttpRequest
protected void startRequest() throws java.io.IOException
startRequest
in class AbstractHttpRequest
java.io.IOException
public java.lang.String getMethod()
getMethod
in class AbstractHttpRequest
public CharSegment getMethodBuffer()
protected CharBuffer getHost()
getHost
in class AbstractHttpRequest
public final byte[] getUriBuffer()
getUriBuffer
in class AbstractHttpRequest
public final int getUriLength()
getUriLength
in class AbstractHttpRequest
public java.lang.String getProtocol()
getProtocol
in class AbstractHttpRequest
public CharSegment getProtocolBuffer()
public boolean isSecure()
isSecure
in class AbstractHttpRequest
public java.lang.String getHeader(java.lang.String key)
getHeader
in class AbstractHttpRequest
key
- the header keypublic CharSegment getHeaderBuffer(java.lang.String key)
AbstractHttpRequest
getHeaderBuffer
in class AbstractHttpRequest
key
- the header namepublic CharSegment getHeaderBuffer(char[] buf, int length)
public void setHeader(java.lang.String key, java.lang.String value)
AbstractHttpRequest
setHeader
in class AbstractHttpRequest
public void getHeaderBuffers(java.lang.String key, java.util.ArrayList<CharSegment> values)
AbstractHttpRequest
getHeaderBuffers
in class AbstractHttpRequest
key
- the header namevalues
- the resulting bufferpublic java.util.Enumeration<java.lang.String> getHeaderNames()
AbstractHttpRequest
getHeaderNames
in class AbstractHttpRequest
public java.lang.String getRequestURI()
getRequestURI
in class AbstractHttpRequest
public java.lang.String getServerName()
getServerName
in class AbstractHttpRequest
public int getServerPort()
AbstractHttpRequest
getServerPort
in class AbstractHttpRequest
public java.lang.String getRemoteAddr()
getRemoteAddr
in class AbstractHttpRequest
public void getRemoteAddr(CharBuffer cb)
public int printRemoteAddr(byte[] buffer, int offset) throws java.io.IOException
printRemoteAddr
in class AbstractHttpRequest
java.io.IOException
public java.lang.String getRemoteHost()
getRemoteHost
in class AbstractHttpRequest
protected void handleConnectionClose()
handleConnectionClose
in class AbstractHttpRequest
public void finishRequest() throws java.io.IOException
AbstractHttpRequest
finishRequest
in class AbstractHttpRequest
java.io.IOException
protected byte[] getNextBuffer()
protected int getNextStartOffset()
protected int getNextBufferOffset() throws java.io.IOException
java.io.IOException
protected void setNextBufferOffset(int offset) throws java.io.IOException
java.io.IOException
protected byte[] writeNextBuffer(int offset) throws java.io.IOException
java.io.IOException
protected void flushNext() throws java.io.IOException
java.io.IOException
protected final boolean flushNextBuffer() throws java.io.IOException
java.io.IOException
protected void writeTail() throws java.io.IOException
java.io.IOException
public void onCloseConnection()
onCloseConnection
in interface ProtocolConnection
onCloseConnection
in class AbstractHttpRequest
protected java.lang.String getRequestId()
public final java.lang.String dbgId()
dbgId
in class AbstractHttpRequest
public java.lang.String toString()
toString
in class java.lang.Object