Package org.cometd.server.http
Class AbstractHttpTransport
- java.lang.Object
-
- org.cometd.common.AbstractTransport
-
- org.cometd.server.AbstractServerTransport
-
- org.cometd.server.http.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
AAbstractServerTransport.Scheduler
for HTTP-based transports.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 java.lang.String
BROWSER_COOKIE_DOMAIN_OPTION
static java.lang.String
BROWSER_COOKIE_HTTP_ONLY_OPTION
static java.lang.String
BROWSER_COOKIE_MAX_AGE_OPTION
static java.lang.String
BROWSER_COOKIE_NAME_OPTION
static java.lang.String
BROWSER_COOKIE_PARTITIONED_OPTION
static java.lang.String
BROWSER_COOKIE_PATH_OPTION
static java.lang.String
BROWSER_COOKIE_SAME_SITE_OPTION
static java.lang.String
BROWSER_COOKIE_SECURE_OPTION
static java.lang.String
DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
static java.lang.String
HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
static java.lang.String
JSON_DEBUG_OPTION
static java.lang.String
MAX_SESSIONS_PER_BROWSER_OPTION
static java.lang.String
MESSAGE_PARAM
static java.lang.String
MULTI_SESSION_INTERVAL_OPTION
static java.lang.String
PREFIX
static java.lang.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, java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
accept(jakarta.servlet.http.HttpServletRequest request)
protected void
decBrowserId(ServerSessionImpl session, boolean http2)
protected java.lang.String
findBrowserId(AbstractHttpTransport.Context context)
protected java.util.Collection<ServerSessionImpl>
findCurrentSessions(jakarta.servlet.http.HttpServletRequest request)
protected ServerSessionImpl
findSession(java.util.Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message)
protected void
flush(AbstractHttpTransport.Context context, Promise<java.lang.Void> promise)
protected jakarta.servlet.AsyncContext
getAsyncContext(jakarta.servlet.http.HttpServletRequest request)
protected int
getDuplicateMetaConnectHttpResponseCode()
protected long
getMultiSessionInterval()
abstract void
handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
protected void
handleJSONParseException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.String json, java.lang.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(jakarta.servlet.http.HttpServletRequest request)
protected void
processMessages(AbstractHttpTransport.Context context, java.util.List<ServerMessage.Mutable> messages, Promise<java.lang.Void> promise)
protected void
resume(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<java.lang.Void> promise)
protected void
sendError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, java.lang.Throwable failure)
protected java.lang.String
setBrowserId(AbstractHttpTransport.Context context)
protected abstract AbstractHttpTransport.HttpScheduler
suspend(AbstractHttpTransport.Context context, Promise<java.lang.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, java.util.List<ServerMessage> messages, Promise<java.lang.Void> promise)
-
Methods inherited from class org.cometd.server.AbstractServerTransport
allowMessageDeliveryDuringHandshake, destroy, dump, getBayeux, getInterval, getJSONContextServer, getMaxInterval, getMaxLazyTimeout, getMaxMessageSize, getTimeout, isAllowMessageDeliveryDuringHandshake, isHandshakeReconnect, isMetaConnectDeliveryOnly, newMetaConnectCycle, 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 java.lang.String PREFIX
- See Also:
- Constant Field Values
-
JSON_DEBUG_OPTION
public static final java.lang.String JSON_DEBUG_OPTION
- See Also:
- Constant Field Values
-
MESSAGE_PARAM
public static final java.lang.String MESSAGE_PARAM
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_NAME_OPTION
public static final java.lang.String BROWSER_COOKIE_NAME_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_DOMAIN_OPTION
public static final java.lang.String BROWSER_COOKIE_DOMAIN_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_PATH_OPTION
public static final java.lang.String BROWSER_COOKIE_PATH_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_MAX_AGE_OPTION
public static final java.lang.String BROWSER_COOKIE_MAX_AGE_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SECURE_OPTION
public static final java.lang.String BROWSER_COOKIE_SECURE_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_HTTP_ONLY_OPTION
public static final java.lang.String BROWSER_COOKIE_HTTP_ONLY_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_SAME_SITE_OPTION
public static final java.lang.String BROWSER_COOKIE_SAME_SITE_OPTION
- See Also:
- Constant Field Values
-
BROWSER_COOKIE_PARTITIONED_OPTION
public static final java.lang.String BROWSER_COOKIE_PARTITIONED_OPTION
- See Also:
- Constant Field Values
-
MAX_SESSIONS_PER_BROWSER_OPTION
public static final java.lang.String MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
public static final java.lang.String HTTP2_MAX_SESSIONS_PER_BROWSER_OPTION
- See Also:
- Constant Field Values
-
MULTI_SESSION_INTERVAL_OPTION
public static final java.lang.String MULTI_SESSION_INTERVAL_OPTION
- See Also:
- Constant Field Values
-
TRUST_CLIENT_SESSION_OPTION
public static final java.lang.String TRUST_CLIENT_SESSION_OPTION
- See Also:
- Constant Field Values
-
DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
public static final java.lang.String DUPLICATE_META_CONNECT_HTTP_RESPONSE_CODE_OPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractHttpTransport
protected AbstractHttpTransport(BayeuxServerImpl bayeux, java.lang.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(jakarta.servlet.http.HttpServletRequest request)
-
handle
public abstract void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws java.io.IOException, jakarta.servlet.ServletException
- Throws:
java.io.IOException
jakarta.servlet.ServletException
-
suspend
protected abstract AbstractHttpTransport.HttpScheduler suspend(AbstractHttpTransport.Context context, Promise<java.lang.Void> promise, ServerMessage.Mutable message, long timeout)
-
write
protected abstract void write(AbstractHttpTransport.Context context, java.util.List<ServerMessage> messages, Promise<java.lang.Void> promise)
-
processMessages
protected void processMessages(AbstractHttpTransport.Context context, java.util.List<ServerMessage.Mutable> messages, Promise<java.lang.Void> promise)
-
findSession
protected ServerSessionImpl findSession(java.util.Collection<ServerSessionImpl> sessions, ServerMessage.Mutable message)
-
findCurrentSessions
protected java.util.Collection<ServerSessionImpl> findCurrentSessions(jakarta.servlet.http.HttpServletRequest request)
-
isHTTP2
protected boolean isHTTP2(jakarta.servlet.http.HttpServletRequest request)
-
flush
protected void flush(AbstractHttpTransport.Context context, Promise<java.lang.Void> promise)
-
resume
protected void resume(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<java.lang.Void> promise)
-
sendError
protected void sendError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, int code, java.lang.Throwable failure)
-
findBrowserId
protected java.lang.String findBrowserId(AbstractHttpTransport.Context context)
-
setBrowserId
protected java.lang.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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.String json, java.lang.Throwable failure) throws java.io.IOException
- Throws:
java.io.IOException
-
handleMessage
protected void handleMessage(AbstractHttpTransport.Context context, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise)
-
getAsyncContext
protected jakarta.servlet.AsyncContext getAsyncContext(jakarta.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)
-
-