public abstract class AbstractHttpRequest extends AbstractProtocolConnection implements SecurityContextProvider
Modifier and Type | Field and Description |
---|---|
protected static CaseInsensitiveIntMap |
_headerCodes |
static java.lang.String |
JSP_EXCEPTION |
static java.lang.String |
SHUTDOWN |
static boolean[] |
TOKEN |
Modifier | Constructor and Description |
---|---|
protected |
AbstractHttpRequest(ServletService server,
SocketLink conn)
Create a new Request.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
addHeaderInt(char[] keyBuf,
int keyOff,
int keyLen,
CharSegment value)
Adds the header, checking for known values.
|
protected HttpBufferStore |
allocateHttpBufferStore() |
protected Invocation |
buildInvocation(Invocation invocation,
byte[] uri,
int uriLength) |
void |
cleanup() |
protected void |
clearRequest() |
void |
clientDisconnect()
Sets the client disconnect
|
protected abstract AbstractHttpResponse |
createResponse() |
protected java.lang.String |
dbgId() |
java.lang.String |
findSessionIdFromConnection()
For SSL connections, use the SSL identifier.
|
void |
finishInvocation()
Cleans up at the end of the invocation
|
void |
finishRequest()
Cleans up at the end of the request
|
protected AbstractHttpResponse |
getAbstractHttpResponse() |
int |
getAvailable() |
int |
getBufferAvailable() |
java.lang.String |
getCharacterEncoding()
Returns the character encoding of a post.
|
protected CharBuffer |
getCharBuffer() |
SocketLink |
getConnection()
Returns the connection.
|
int |
getConnectionId() |
int |
getContentLength()
Returns the content length of a post.
|
java.lang.String |
getContentType()
Returns the content-length of a post.
|
CharSegment |
getContentTypeBuffer()
Returns the content-length of a post.
|
Cookie[] |
getCookies()
Returns the cookies from the browser
|
long |
getDateHeader(java.lang.String key)
Returns a header interpreted as a date.
|
protected ErrorPageManager |
getErrorManager()
Returns the default error manager
|
protected HashMapImpl<java.lang.String,java.lang.String[]> |
getForm() |
protected Form |
getFormParser() |
protected CharSegment |
getForwardedHostHeader() |
abstract java.lang.String |
getHeader(java.lang.String key)
Returns the named header.
|
CharSegment |
getHeaderBuffer(java.lang.String name)
Fills the result with the header values as
CharSegment values.
|
void |
getHeaderBuffers(java.lang.String name,
java.util.ArrayList<CharSegment> resultList)
Fills the result with a list of the header values as
CharSegment values.
|
CharSegment |
getHeaderKey(int index)
Returns the header key
|
abstract java.util.Enumeration<java.lang.String> |
getHeaderNames()
Enumerates the header keys
|
java.util.Enumeration<java.lang.String> |
getHeaders(java.lang.String name)
Returns an enumeration of the headers for the named attribute.
|
int |
getHeaderSize()
Returns the number of headers.
|
CharSegment |
getHeaderValue(int index)
Returns the header value
|
protected java.lang.CharSequence |
getHost() |
protected CharSegment |
getHostHeader() |
protected HttpBufferStore |
getHttpBufferStore()
Returns the http buffer store
|
ServletInputStream |
getInputStream()
Returns a stream for reading POST data.
|
int |
getIntHeader(java.lang.String key)
Returns the named header, converted to an integer.
|
protected Invocation |
getInvocation(java.lang.CharSequence host,
byte[] uri,
int uriLength) |
InvocationServer |
getInvocationServer()
returns the dispatch server.
|
java.util.Locale |
getLocale() |
java.util.Enumeration<java.util.Locale> |
getLocales() |
java.lang.String |
getLocalHost()
Returns the server's address.
|
int |
getLocalPort()
Returns the local port.
|
long |
getLongContentLength()
Returns the content length of a post.
|
abstract java.lang.String |
getMethod() |
abstract java.lang.String |
getProtocol() |
java.lang.String |
getProtocolRequestURL()
Returns a default debugging identifier for the connection
|
ReadStream |
getRawInput()
Returns the raw input stream.
|
ReadStream |
getRawRead() |
byte[] |
getRawReadBuffer()
Returns the raw read buffer.
|
WriteStream |
getRawWrite() |
java.io.BufferedReader |
getReader()
Returns a Reader for the POST contents
|
ReadStream |
getReadStream() |
java.lang.String |
getRemoteAddr() |
java.lang.String |
getRemoteHost() |
int |
getRemotePort()
Returns the local port.
|
HttpServletRequestImpl |
getRequestFacade() |
java.lang.String |
getRequestURI() |
java.lang.StringBuffer |
getRequestURL() |
AbstractHttpResponse |
getResponse()
Returns the response for this request.
|
HttpServletResponseImpl |
getResponseFacade() |
java.lang.String |
getScheme()
Returns the request's scheme.
|
ServletService |
getServer() |
java.lang.String |
getServerName()
Returns the local server name.
|
int |
getServerPort()
Returns the server's port.
|
protected char[] |
getSmallHeaderBuffer() |
protected CharSegment[] |
getSmallHeaderKeys() |
protected CharSegment[] |
getSmallHeaderValues() |
protected byte[] |
getSmallUriBuffer() |
long |
getStartTime()
Returns the date for the current request.
|
ReadStream |
getStream()
Returns the requests underlying read stream, e.g.
|
ReadStream |
getStream(boolean isReader)
Returns the requests underlying read stream, e.g.
|
TcpSocketLink |
getTcpSocketLink() |
abstract byte[] |
getUriBuffer() |
abstract int |
getUriLength() |
java.security.Principal |
getUserPrincipal()
Returns the Principal for the context.
|
protected WebApp |
getWebApp() |
protected void |
handleConnectionClose()
Called for a connection: close
|
boolean |
handleResume()
Handles a comet-style resume.
|
boolean |
hasRequest()
Returns true if a request has been set
|
void |
init()
Initialization.
|
protected void |
initAttributes(HttpServletRequestImpl facade) |
protected abstract boolean |
initStream(ReadStream readStream,
ReadStream rawStream)
Initialize the read stream from the raw stream.
|
boolean |
isCometActive() |
boolean |
isConnectionClosed()
Returns true if the client has disconnected
|
boolean |
isDuplex() |
boolean |
isIgnoreClientDisconnect()
Returns true if client disconnects should be ignored.
|
protected boolean |
isKeepalive()
Returns true if the keepalive is active.
|
boolean |
isSecure()
Returns true if the request is secure.
|
boolean |
isSuspend() |
boolean |
isTransportSecure()
Returns true if the transport is secure.
|
boolean |
isUserInRole(java.lang.String role)
Returns true if the user principal plays the named role.
|
void |
killKeepalive(java.lang.String reason)
Kills the keepalive.
|
void |
onAttachThread()
Returns the log buffer.
|
void |
onCloseConnection()
Handles a close event when the connection is closed.
|
void |
onDetachThread()
Called when the connection is detached from a thread
|
void |
onStartConnection()
Called when the connection starts
|
int |
printRemoteAddr(byte[] buffer,
int offset) |
protected void |
restartServer()
Restarts the server.
|
java.lang.String |
runAs(java.lang.String string)
Sets the current runAs role/principal.
|
protected void |
sendRequestError(java.lang.Throwable e) |
void |
setCharacterEncoding(java.lang.String encoding)
Sets the character encoding of a post.
|
protected void |
setContentLength(CharSegment value) |
void |
setHeader(java.lang.String key,
java.lang.String value)
Sets the header.
|
void |
shutdown()
Called by server shutdown to kill any active threads
|
protected void |
skip() |
SocketLinkDuplexController |
startDuplex(SocketLinkDuplexListener handler)
Starts duplex mode.
|
protected void |
startInvocation()
Prepare the Request object for a new request.
|
protected void |
startRequest()
Prepare the Request object for a new request.
|
handleRequest
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isWaitForRead
protected static final CaseInsensitiveIntMap _headerCodes
public static final java.lang.String JSP_EXCEPTION
public static final java.lang.String SHUTDOWN
public static final boolean[] TOKEN
protected AbstractHttpRequest(ServletService server, SocketLink conn)
server
- the parent serverpublic ServletService getServer()
protected abstract AbstractHttpResponse createResponse()
protected AbstractHttpResponse getAbstractHttpResponse()
public void init()
init
in interface ProtocolConnection
init
in class AbstractProtocolConnection
public final SocketLink getConnection()
public final TcpSocketLink getTcpSocketLink()
public final int getConnectionId()
public final InvocationServer getInvocationServer()
protected final CharBuffer getCharBuffer()
public void onStartConnection()
onStartConnection
in interface ProtocolConnection
onStartConnection
in class AbstractProtocolConnection
protected void startRequest() throws java.io.IOException
httpBuffer
- the raw connection streamjava.io.IOException
protected void clearRequest()
public boolean hasRequest()
protected final byte[] getSmallUriBuffer()
protected final char[] getSmallHeaderBuffer()
protected final CharSegment[] getSmallHeaderKeys()
protected final CharSegment[] getSmallHeaderValues()
protected final HttpBufferStore getHttpBufferStore()
protected final HttpBufferStore allocateHttpBufferStore()
public WriteStream getRawWrite()
public abstract byte[] getUriBuffer()
public abstract int getUriLength()
public boolean isIgnoreClientDisconnect()
protected WebApp getWebApp()
public java.lang.StringBuffer getRequestURL()
public java.lang.String getRequestURI()
public java.lang.String getProtocolRequestURL()
AbstractProtocolConnection
getProtocolRequestURL
in interface ProtocolConnection
getProtocolRequestURL
in class AbstractProtocolConnection
protected CharSegment getHostHeader()
protected CharSegment getForwardedHostHeader()
public boolean isConnectionClosed()
public void clientDisconnect()
public final HttpServletRequestImpl getRequestFacade()
public final HttpServletResponseImpl getResponseFacade()
public AbstractHttpResponse getResponse()
public java.lang.String getServerName()
protected java.lang.CharSequence getHost()
public int getServerPort()
public int getLocalPort()
public java.lang.String getLocalHost()
public java.lang.String getRemoteAddr()
public int printRemoteAddr(byte[] buffer, int offset) throws java.io.IOException
java.io.IOException
public java.lang.String getRemoteHost()
public int getRemotePort()
public java.lang.String getScheme()
public abstract java.lang.String getProtocol()
public abstract java.lang.String getMethod()
public abstract java.lang.String getHeader(java.lang.String key)
key
- the header keypublic int getHeaderSize()
public CharSegment getHeaderKey(int index)
public CharSegment getHeaderValue(int index)
public CharSegment getHeaderBuffer(java.lang.String name)
name
- the header namepublic abstract java.util.Enumeration<java.lang.String> getHeaderNames()
public void setHeader(java.lang.String key, java.lang.String value)
protected boolean addHeaderInt(char[] keyBuf, int keyOff, int keyLen, CharSegment value)
protected void setContentLength(CharSegment value)
protected void handleConnectionClose()
public java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
name
- the header namepublic void getHeaderBuffers(java.lang.String name, java.util.ArrayList<CharSegment> resultList)
name
- the header nameresultList
- the resulting bufferpublic int getIntHeader(java.lang.String key)
key
- the header key.public long getDateHeader(java.lang.String key)
key
- the header key.public int getContentLength()
public long getLongContentLength()
public java.lang.String getContentType()
public CharSegment getContentTypeBuffer()
public java.lang.String getCharacterEncoding()
public void setCharacterEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public Cookie[] getCookies()
public java.lang.String findSessionIdFromConnection()
public boolean isTransportSecure()
isTransportSecure
in interface SecurityContextProvider
public ReadStream getStream() throws java.io.IOException
java.io.IOException
public ReadStream getStream(boolean isReader) throws java.io.IOException
java.io.IOException
public final ReadStream getRawRead()
public final ReadStream getReadStream()
public byte[] getRawReadBuffer()
public int getAvailable() throws java.io.IOException
java.io.IOException
public int getBufferAvailable() throws java.io.IOException
java.io.IOException
protected void skip() throws java.io.IOException
java.io.IOException
protected abstract boolean initStream(ReadStream readStream, ReadStream rawStream) throws java.io.IOException
java.io.IOException
public ReadStream getRawInput()
public final ServletInputStream getInputStream() throws java.io.IOException
java.io.IOException
public final java.io.BufferedReader getReader() throws java.io.IOException
java.io.IOException
protected void initAttributes(HttpServletRequestImpl facade)
public java.util.Locale getLocale()
public java.util.Enumeration<java.util.Locale> getLocales()
public boolean isSecure()
public java.lang.String runAs(java.lang.String string)
SecurityContextProvider
isUserInRole
and getUserPrincipal
.runAs
in interface SecurityContextProvider
string
- the new rolepublic boolean isUserInRole(java.lang.String role)
SecurityContextProvider
isUserInRole
in interface SecurityContextProvider
role
- the permission to test against.public java.security.Principal getUserPrincipal()
SecurityContextProvider
getUserPrincipal
in interface SecurityContextProvider
public final long getStartTime()
public final void onAttachThread()
onAttachThread
in interface ProtocolConnection
onAttachThread
in class AbstractProtocolConnection
public final void onDetachThread()
AbstractProtocolConnection
onDetachThread
in interface ProtocolConnection
onDetachThread
in class AbstractProtocolConnection
protected Invocation getInvocation(java.lang.CharSequence host, byte[] uri, int uriLength) throws java.io.IOException
java.io.IOException
protected Invocation buildInvocation(Invocation invocation, byte[] uri, int uriLength) throws java.io.IOException
java.io.IOException
public boolean handleResume() throws java.io.IOException
handleResume
in interface ProtocolConnection
handleResume
in class AbstractProtocolConnection
java.io.IOException
public SocketLinkDuplexController startDuplex(SocketLinkDuplexListener handler)
protected void sendRequestError(java.lang.Throwable e) throws java.io.IOException
java.io.IOException
protected ErrorPageManager getErrorManager()
public void killKeepalive(java.lang.String reason)
protected boolean isKeepalive()
public boolean isCometActive()
public boolean isSuspend()
public boolean isDuplex()
protected HashMapImpl<java.lang.String,java.lang.String[]> getForm()
protected Form getFormParser()
protected void restartServer()
protected void startInvocation() throws java.io.IOException
java.io.IOException
public void finishInvocation()
public void finishRequest() throws java.io.IOException
java.io.IOException
public void onCloseConnection()
AbstractProtocolConnection
onCloseConnection
in interface ProtocolConnection
onCloseConnection
in class AbstractProtocolConnection
public void cleanup()
public void shutdown()
protected java.lang.String dbgId()