Package org.cometd.server.transport
Class AbstractHttpTransport
java.lang.Object
org.cometd.common.AbstractTransport
org.cometd.server.AbstractServerTransport
org.cometd.server.transport.AbstractHttpTransport
- All Implemented Interfaces:
ServerTransport
,Transport
,org.eclipse.jetty.util.component.Dumpable
- Direct Known Subclasses:
AbstractStreamHttpTransport
,AsyncJSONTransport
public abstract class AbstractHttpTransport extends AbstractServerTransport
HTTP ServerTransport base class, used by ServerTransports that use HTTP as transport or to initiate a transport connection.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractHttpTransport.HttpScheduler
protected class
AbstractHttpTransport.LongPollScheduler
Nested classes/interfaces inherited from class org.cometd.server.AbstractServerTransport
AbstractServerTransport.Scheduler
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
_logger
static String
BROWSER_COOKIE_DOMAIN_OPTION
static String
BROWSER_COOKIE_HTTP_ONLY_OPTION
static String
BROWSER_COOKIE_NAME_OPTION
static String
BROWSER_COOKIE_PATH_OPTION
static String
BROWSER_COOKIE_SAME_SITE_OPTION
static String
BROWSER_COOKIE_SECURE_OPTION
static String
DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
static String
HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
static String
JSON_DEBUG_OPTION
static String
MAX_SESSIONS_PER_BROWSER_OPTION
static String
MESSAGE_PARAM
static String
MULTI_SESSION_INTERVAL_OPTION
static String
PREFIX
static String
TRUST_CLIENT_SESSION
Deprecated.use #TRUST_CLIENT_SESSION_OPTIONstatic String
TRUST_CLIENT_SESSION_OPTION
Fields inherited from class org.cometd.server.AbstractServerTransport
ALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKE, HANDSHAKE_RECONNECT_OPTION, INTERVAL_OPTION, JSON_CONTEXT_OPTION, MAX_INTERVAL_OPTION, MAX_LAZY_TIMEOUT_OPTION, MAX_MESSAGE_SIZE_OPTION, MAX_PROCESSING_OPTION, MAX_QUEUE_OPTION, META_CONNECT_DELIVERY_OPTION, TIMEOUT_OPTION
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractHttpTransport(BayeuxServerImpl bayeux, String name)
-
Method Summary
Modifier and Type Method Description abstract boolean
accept(javax.servlet.http.HttpServletRequest request)
protected ServerMessage.Mutable
bayeuxServerHandle(ServerSessionImpl session, ServerMessage.Mutable message)
protected void
decBrowserId(ServerSessionImpl session, boolean http2)
protected void
error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, int responseCode)
protected String
findBrowserId(javax.servlet.http.HttpServletRequest request)
protected Collection<ServerSessionImpl>
findCurrentSessions(javax.servlet.http.HttpServletRequest request)
protected ServerSessionImpl
findSession(Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message)
protected void
flush(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, boolean sendQueue, boolean scheduleExpiration, ServerMessage.Mutable... replies)
protected javax.servlet.AsyncContext
getAsyncContext(javax.servlet.http.HttpServletRequest request)
BayeuxContext
getContext()
javax.servlet.http.HttpServletRequest
getCurrentRequest()
protected long
getMultiSessionInterval()
abstract void
handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected void
handleJSONParseException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String json, Throwable exception)
protected boolean
incBrowserId(ServerSessionImpl session, boolean http2)
Increments the count of sessions for the given browser identifier.void
init()
Initializes the transport, resolving default and direct options.protected boolean
isHTTP2(javax.servlet.http.HttpServletRequest request)
protected void
metaConnectResumed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSession session)
protected void
metaConnectSuspended(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSession session)
protected void
processMessages(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerMessage.Mutable[] messages)
protected ServerMessage.Mutable
processMetaConnect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable message, boolean canSuspend)
protected ServerMessage.Mutable
processMetaHandshake(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable message)
protected void
resume(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSessionImpl session, ServerMessage.Mutable reply)
protected String
setBrowserId(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
void
setCurrentRequest(javax.servlet.http.HttpServletRequest request)
protected abstract AbstractHttpTransport.HttpScheduler
suspend(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable reply, long timeout)
protected void
sweep()
Sweeps the transport for old Browser IDsprotected abstract void
write(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, boolean scheduleExpiration, List<ServerMessage> messages, ServerMessage.Mutable[] replies)
Methods inherited from class org.cometd.server.AbstractServerTransport
allowMessageDeliveryDuringHandshake, destroy, dump, dump, getAdvice, getBayeux, getInterval, getMaxInterval, getMaxLazyTimeout, getMaxMessageSize, getTimeout, isAllowMessageDeliveryDuringHandshake, isHandshakeReconnect, isMetaConnectDeliveryOnly, parseMessages, parseMessages, processReply, scheduleExpiration, setAllowMessageDeliveryDuringHandshake, setHandshakeReconnect, setInterval, setMaxInterval, setMaxLazyTimeout, setMaxMessageSize, setMetaConnectDeliveryOnly, setTimeout, toJSONBytes, toString
Methods inherited from class org.cometd.common.AbstractTransport
getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, setOption, setOptionPrefix
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cometd.bayeux.Transport
getName, getOption, getOptionNames, getOptionPrefix
-
Field Details
-
PREFIX
- See Also:
- Constant Field Values
-
JSON_DEBUG_OPTION
- See Also:
- Constant Field Values
-
MESSAGE_PARAM
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_NAME_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_DOMAIN_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_PATH_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SECURE_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_HTTP_ONLY_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SAME_SITE_OPTION
- See Also:
- Constant Field Values
-
MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
MULTI_SESSION_INTERVAL_OPTION
- See Also:
- Constant Field Values
-
TRUST_CLIENT_SESSION_OPTION
- See Also:
- Constant Field Values
-
DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
- See Also:
- Constant Field Values
-
TRUST_CLIENT_SESSION
Deprecated.use #TRUST_CLIENT_SESSION_OPTION- See Also:
- Constant Field Values
-
_logger
protected final org.slf4j.Logger _logger
-
-
Constructor Details
-
Method Details
-
init
public void init()Description copied from class:AbstractServerTransport
Initializes the transport, resolving default and direct options.- Overrides:
init
in classAbstractServerTransport
-
getMultiSessionInterval
protected long getMultiSessionInterval() -
setCurrentRequest
public void setCurrentRequest(javax.servlet.http.HttpServletRequest request) -
getCurrentRequest
public javax.servlet.http.HttpServletRequest getCurrentRequest() -
accept
public abstract boolean accept(javax.servlet.http.HttpServletRequest request) -
handle
public abstract void handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException- Throws:
IOException
javax.servlet.ServletException
-
suspend
protected abstract AbstractHttpTransport.HttpScheduler suspend(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable reply, long timeout) -
write
protected abstract void write(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, boolean scheduleExpiration, List<ServerMessage> messages, ServerMessage.Mutable[] replies) -
processMessages
protected void processMessages(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerMessage.Mutable[] messages) throws IOException- Throws:
IOException
-
findSession
protected ServerSessionImpl findSession(Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message) -
findCurrentSessions
protected Collection<ServerSessionImpl> findCurrentSessions(javax.servlet.http.HttpServletRequest request) -
processMetaHandshake
protected ServerMessage.Mutable processMetaHandshake(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable message) -
processMetaConnect
protected ServerMessage.Mutable processMetaConnect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, ServerMessage.Mutable message, boolean canSuspend) -
isHTTP2
protected boolean isHTTP2(javax.servlet.http.HttpServletRequest request) -
flush
protected void flush(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ServerSessionImpl session, boolean sendQueue, boolean scheduleExpiration, ServerMessage.Mutable... replies) -
resume
protected void resume(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSessionImpl session, ServerMessage.Mutable reply) -
getContext
- Returns:
- The current transport context or null if no current context
-
findBrowserId
-
setBrowserId
protected String setBrowserId(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) -
incBrowserId
Increments the count of sessions for the given browser identifier.- Parameters:
session
- the session that increments the counthttp2
- whether the HTTP protocol is HTTP/2- Returns:
- true if the count is below the max sessions per browser value. If false is returned, the count is not incremented.
- See Also:
decBrowserId(ServerSessionImpl, boolean)
-
decBrowserId
-
handleJSONParseException
protected void handleJSONParseException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String json, Throwable exception) throws IOException- Throws:
IOException
-
getAsyncContext
protected javax.servlet.AsyncContext getAsyncContext(javax.servlet.http.HttpServletRequest request) -
error
protected void error(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, int responseCode) -
bayeuxServerHandle
protected ServerMessage.Mutable bayeuxServerHandle(ServerSessionImpl session, ServerMessage.Mutable message) -
metaConnectSuspended
protected void metaConnectSuspended(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSession session) -
metaConnectResumed
protected void metaConnectResumed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.AsyncContext asyncContext, ServerSession session) -
sweep
protected void sweep()Sweeps the transport for old Browser IDs- Overrides:
sweep
in classAbstractServerTransport
-