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 class
AbstractHttpTransport.Context
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 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
_logger, 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
accept(javax.servlet.http.HttpServletRequest request)
protected void
decBrowserId(ServerSessionImpl session, boolean http2)
protected String
findBrowserId(AbstractHttpTransport.Context context)
protected Collection<ServerSessionImpl>
findCurrentSessions(javax.servlet.http.HttpServletRequest request)
protected ServerSessionImpl
findSession(Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message)
protected void
flush(AbstractHttpTransport.Context context, Promise<Void> promise)
protected javax.servlet.AsyncContext
getAsyncContext(javax.servlet.http.HttpServletRequest request)
protected int
getDuplicateMetaConnectHttpResponseCode()
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 failure)
protected void
handleMessage(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise)
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
processMessages(AbstractHttpTransport.Context context, ServerMessage.Mutable[] messages, Promise<Void> promise)
protected void
resume(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<Void> promise)
protected void
sendError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int code, Throwable failure)
protected String
setBrowserId(AbstractHttpTransport.Context context)
protected abstract AbstractHttpTransport.HttpScheduler
suspend(AbstractHttpTransport.Context context, Promise<Void> promise, ServerMessage.Mutable message, long timeout)
protected void
sweep()
Sweeps the transport for old Browser IDsprotected byte[]
toJSONBytes(ServerMessage msg)
protected abstract void
write(AbstractHttpTransport.Context context, List<ServerMessage> messages, Promise<Void> promise)
-
Methods inherited from class org.cometd.server.AbstractServerTransport
allowMessageDeliveryDuringHandshake, destroy, dump, getBayeux, getInterval, getMaxInterval, getMaxLazyTimeout, getMaxMessageSize, getTimeout, isAllowMessageDeliveryDuringHandshake, isHandshakeReconnect, isMetaConnectDeliveryOnly, parseMessages, parseMessages, processReply, scheduleExpiration, setAllowMessageDeliveryDuringHandshake, setHandshakeReconnect, setInterval, setMaxInterval, setMaxLazyTimeout, setMaxMessageSize, setMetaConnectDeliveryOnly, setTimeout, toJSON, 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 Detail
-
PREFIX
public static final String PREFIX
- See Also:
- Constant Field Values
-
JSON_DEBUG_OPTION
public static final String JSON_DEBUG_OPTION
- See Also:
- Constant Field Values
-
MESSAGE_PARAM
public static final String MESSAGE_PARAM
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_NAME_OPTION
public static final String BROWSER_COOKIE_NAME_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_DOMAIN_OPTION
public static final String BROWSER_COOKIE_DOMAIN_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_PATH_OPTION
public static final String BROWSER_COOKIE_PATH_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SECURE_OPTION
public static final String BROWSER_COOKIE_SECURE_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_HTTP_ONLY_OPTION
public static final String BROWSER_COOKIE_HTTP_ONLY_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SAME_SITE_OPTION
public static final String BROWSER_COOKIE_SAME_SITE_OPTION
- See Also:
- Constant Field Values
-
MAX_SESSIONS_PER_BROWSER_OPTION
public static final String MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
public static final String HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
MULTI_SESSION_INTERVAL_OPTION
public static final String MULTI_SESSION_INTERVAL_OPTION
- See Also:
- Constant Field Values
-
TRUST_CLIENT_SESSION_OPTION
public static final String TRUST_CLIENT_SESSION_OPTION
- See Also:
- Constant Field Values
-
DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
public static final String DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
- See Also:
- Constant Field Values
-
TRUST_CLIENT_SESSION
@Deprecated public static final String TRUST_CLIENT_SESSION
Deprecated.use #TRUST_CLIENT_SESSION_OPTION- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractHttpTransport
protected AbstractHttpTransport(BayeuxServerImpl bayeux, String name)
-
-
Method Detail
-
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()
-
getDuplicateMetaConnectHttpResponseCode
protected int getDuplicateMetaConnectHttpResponseCode()
-
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(AbstractHttpTransport.Context context, Promise<Void> promise, ServerMessage.Mutable message, long timeout)
-
write
protected abstract void write(AbstractHttpTransport.Context context, List<ServerMessage> messages, Promise<Void> promise)
-
processMessages
protected void processMessages(AbstractHttpTransport.Context context, ServerMessage.Mutable[] messages, Promise<Void> promise)
-
findSession
protected ServerSessionImpl findSession(Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message)
-
findCurrentSessions
protected Collection<ServerSessionImpl> findCurrentSessions(javax.servlet.http.HttpServletRequest request)
-
isHTTP2
protected boolean isHTTP2(javax.servlet.http.HttpServletRequest request)
-
flush
protected void flush(AbstractHttpTransport.Context context, Promise<Void> promise)
-
resume
protected void resume(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<Void> promise)
-
sendError
protected void sendError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int code, Throwable failure)
-
findBrowserId
protected String findBrowserId(AbstractHttpTransport.Context context)
-
setBrowserId
protected String setBrowserId(AbstractHttpTransport.Context context)
-
incBrowserId
protected boolean incBrowserId(ServerSessionImpl session, boolean http2)
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
protected void decBrowserId(ServerSessionImpl session, boolean http2)
-
handleJSONParseException
protected void handleJSONParseException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String json, Throwable failure) throws IOException
- Throws:
IOException
-
handleMessage
protected void handleMessage(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise)
-
getAsyncContext
protected javax.servlet.AsyncContext getAsyncContext(javax.servlet.http.HttpServletRequest request)
-
sweep
protected void sweep()
Sweeps the transport for old Browser IDs- Overrides:
sweep
in classAbstractServerTransport
-
toJSONBytes
protected byte[] toJSONBytes(ServerMessage msg)
-
-