Package org.eclipse.jetty.server
Class HttpChannelState
- java.lang.Object
-
- org.eclipse.jetty.server.HttpChannelState
-
public class HttpChannelState extends java.lang.ObjectImplementation of AsyncContext interface that holds the state of request-response cycle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpChannelState.ActionThe actions to take as the channel moves from state to state.private static classHttpChannelState.InputStateprivate static classHttpChannelState.OutputStateprivate static classHttpChannelState.RequestStatestatic classHttpChannelState.State
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<javax.servlet.AsyncListener>_asyncListenersprivate boolean_asyncWritePossibleprivate HttpChannel_channelprivate AsyncContextEvent_eventprivate boolean_initialprivate HttpChannelState.InputState_inputStateprivate java.lang.Thread_onTimeoutThreadprivate HttpChannelState.OutputState_outputStateprivate HttpChannelState.RequestState_requestStateprivate boolean_sendErrorprivate HttpChannelState.State_stateprivate long_timeoutMsprivate static longDEFAULT_TIMEOUTprivate static LoggerLOG
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpChannelState(HttpChannel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanabortResponse()voidaddListener(javax.servlet.AsyncListener listener)voidasyncError(java.lang.Throwable failure)protected voidcancelTimeout()protected voidcancelTimeout(AsyncContextEvent event)booleancommitResponse()voidcomplete()protected voidcompleted(java.lang.Throwable failure)booleancompleteResponse()protected voidcompleting()voiddispatch(javax.servlet.ServletContext context, java.lang.String path)AsyncContextEventgetAsyncContextEvent()java.lang.ObjectgetAttribute(java.lang.String name)RequestgetBaseRequest()ContextHandlergetContextHandler()(package private) ContextHandlergetContextHandler(AsyncContextEvent event)HttpChannelgetHttpChannel()javax.servlet.ServletResponsegetServletResponse()javax.servlet.ServletResponsegetServletResponse(AsyncContextEvent event)HttpChannelState.StategetState()java.lang.StringgetStatusString()private java.lang.StringgetStatusStringLocked()longgetTimeout()HttpChannelState.Actionhandling()booleanhasListener(javax.servlet.AsyncListener listener)booleanisAsync()booleanisAsyncStarted()(package private) booleanisCompleted()booleanisExpired()booleanisIdle()booleanisInitial()booleanisResponseCommitted()booleanisResponseCompleted()booleanisSendError()booleanisSuspended()private HttpChannelState.ActionnextAction(boolean handling)booleanonContentAdded()Called to signal that content is now available to read.protected voidonError(java.lang.Throwable th)booleanonReadEof()Called to signal that a read has read -1.booleanonReadPossible()Called to indicate that more content may be available, but that a handling thread may need to produce (fill/parse) it.booleanonReadReady()Called to signal that the channel is ready for a callback.voidonReadUnready()Called to signal async read isReady() has returned false.protected voidonTimeout()booleanonWritePossible()booleanpartialResponse()protected voidrecycle()voidremoveAttribute(java.lang.String name)(package private) voidrunInContext(AsyncContextEvent event, java.lang.Runnable runnable)protected voidscheduleDispatch()voidsendError(int code, java.lang.String message)private voidsendError(java.lang.Throwable th)voidsetAttribute(java.lang.String name, java.lang.Object attribute)voidsetTimeout(long ms)voidstartAsync(AsyncContextEvent event)protected voidtimeout()java.lang.StringtoString()private java.lang.StringtoStringLocked()protected HttpChannelState.Actionunhandle()Signal that the HttpConnection has finished handling the request.voidupgrade()
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
DEFAULT_TIMEOUT
private static final long DEFAULT_TIMEOUT
-
_channel
private final HttpChannel _channel
-
_asyncListeners
private java.util.List<javax.servlet.AsyncListener> _asyncListeners
-
_state
private HttpChannelState.State _state
-
_requestState
private HttpChannelState.RequestState _requestState
-
_outputState
private HttpChannelState.OutputState _outputState
-
_inputState
private HttpChannelState.InputState _inputState
-
_initial
private boolean _initial
-
_sendError
private boolean _sendError
-
_asyncWritePossible
private boolean _asyncWritePossible
-
_timeoutMs
private long _timeoutMs
-
_event
private AsyncContextEvent _event
-
_onTimeoutThread
private java.lang.Thread _onTimeoutThread
-
-
Constructor Detail
-
HttpChannelState
protected HttpChannelState(HttpChannel channel)
-
-
Method Detail
-
getState
public HttpChannelState.State getState()
-
addListener
public void addListener(javax.servlet.AsyncListener listener)
-
hasListener
public boolean hasListener(javax.servlet.AsyncListener listener)
-
isSendError
public boolean isSendError()
-
setTimeout
public void setTimeout(long ms)
-
getTimeout
public long getTimeout()
-
getAsyncContextEvent
public AsyncContextEvent getAsyncContextEvent()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringLocked
private java.lang.String toStringLocked()
-
getStatusStringLocked
private java.lang.String getStatusStringLocked()
-
getStatusString
public java.lang.String getStatusString()
-
commitResponse
public boolean commitResponse()
-
partialResponse
public boolean partialResponse()
-
completeResponse
public boolean completeResponse()
-
isResponseCommitted
public boolean isResponseCommitted()
-
isResponseCompleted
public boolean isResponseCompleted()
-
abortResponse
public boolean abortResponse()
-
handling
public HttpChannelState.Action handling()
- Returns:
- Next handling of the request should proceed
-
unhandle
protected HttpChannelState.Action unhandle()
Signal that the HttpConnection has finished handling the request. For blocking connectors, this call may block if the request has been suspended (startAsync called).- Returns:
- next actions be handled again (eg because of a resume that happened before unhandle was called)
-
nextAction
private HttpChannelState.Action nextAction(boolean handling)
-
startAsync
public void startAsync(AsyncContextEvent event)
-
dispatch
public void dispatch(javax.servlet.ServletContext context, java.lang.String path)
-
timeout
protected void timeout()
-
onTimeout
protected void onTimeout()
-
complete
public void complete()
-
asyncError
public void asyncError(java.lang.Throwable failure)
-
onError
protected void onError(java.lang.Throwable th)
-
sendError
private void sendError(java.lang.Throwable th)
-
sendError
public void sendError(int code, java.lang.String message)
-
completing
protected void completing()
-
completed
protected void completed(java.lang.Throwable failure)
-
recycle
protected void recycle()
-
upgrade
public void upgrade()
-
scheduleDispatch
protected void scheduleDispatch()
-
cancelTimeout
protected void cancelTimeout()
-
cancelTimeout
protected void cancelTimeout(AsyncContextEvent event)
-
isIdle
public boolean isIdle()
-
isExpired
public boolean isExpired()
-
isInitial
public boolean isInitial()
-
isSuspended
public boolean isSuspended()
-
isCompleted
boolean isCompleted()
-
isAsyncStarted
public boolean isAsyncStarted()
-
isAsync
public boolean isAsync()
-
getBaseRequest
public Request getBaseRequest()
-
getHttpChannel
public HttpChannel getHttpChannel()
-
getContextHandler
public ContextHandler getContextHandler()
-
getContextHandler
ContextHandler getContextHandler(AsyncContextEvent event)
-
getServletResponse
public javax.servlet.ServletResponse getServletResponse()
-
getServletResponse
public javax.servlet.ServletResponse getServletResponse(AsyncContextEvent event)
-
runInContext
void runInContext(AsyncContextEvent event, java.lang.Runnable runnable)
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
-
removeAttribute
public void removeAttribute(java.lang.String name)
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object attribute)
-
onReadUnready
public void onReadUnready()
Called to signal async read isReady() has returned false. This indicates that there is no content available to be consumed and that once the channel enters the ASYNC_WAIT state it will register for read interest by callingHttpChannel.onAsyncWaitForContent()either from this method or from a subsequent call tounhandle().
-
onContentAdded
public boolean onContentAdded()
Called to signal that content is now available to read. If the channel is in ASYNC_WAIT state and unready (ie isReady() has returned false), then the state is changed to ASYNC_WOKEN and true is returned.- Returns:
- True IFF the channel was unready and in ASYNC_WAIT state
-
onReadReady
public boolean onReadReady()
Called to signal that the channel is ready for a callback. This is similar to callingonReadUnready()followed byonContentAdded(), except that as content is already available, read interest is never set.- Returns:
- true if woken
-
onReadPossible
public boolean onReadPossible()
Called to indicate that more content may be available, but that a handling thread may need to produce (fill/parse) it. Typically called by the async read success callback.- Returns:
trueif more content may be available
-
onReadEof
public boolean onReadEof()
Called to signal that a read has read -1. Will wake if the read was called while in ASYNC_WAIT state- Returns:
trueif woken
-
onWritePossible
public boolean onWritePossible()
-
-