Top Description Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

pack-priv Class ServletCoreRequest

extends Object
implements Request
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.Request, org.eclipse.jetty.io.Content.Source, org.eclipse.jetty.util.Attributes
Imports
java.util.Enumeration, .HashSet, .Set, java.util.concurrent.TimeoutException, java.util.function.Consumer, .Function, .Predicate, jakarta.servlet.DispatcherType, .RequestDispatcher, jakarta.servlet.http.HttpServletRequest, org.eclipse.jetty.http.HttpField, .HttpFields, .HttpURI, org.eclipse.jetty.io.Content, org.eclipse.jetty.server.Components, .ConnectionMetaData, .Context, .HttpStream, .Request, .Session, .TunnelSupport, org.eclipse.jetty.util.URIUtil

Wrap a jakarta.servlet.ServletRequest as a core Request.

Whilst similar to a Request.Wrapper, this class is not a Wrapper as callers should not be able to access Wrapper#getWrapped() and bypass the jakarta.servlet.ServletRequest.

The current implementation does not support any read operations.

Field Summary

Modifier and TypeField and Description
private final HttpFields
private final ServletContextRequest
private final HttpServletRequest
private final HttpURI

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addFailureListener(Consumer<Throwable>
the failure listener as a consumer function
onFailure
)

Implements org.eclipse.jetty.server.Request.addFailureListener.

Adds a listener for asynchronous fatal failures.

public void
addHttpStreamWrapper(Function<HttpStream, HttpStream>
A function that wraps the passed stream.
wrapper
)

Implements org.eclipse.jetty.server.Request.addHttpStreamWrapper.

Add a HttpStream.Wrapper to the current HttpStream.
public void
addIdleTimeoutListener(Predicate<TimeoutException>
the idle timeout listener as a predicate function
onIdleTimeout
)

Implements org.eclipse.jetty.server.Request.addIdleTimeoutListener.

Adds a listener for idle timeouts.

public void
clearAttributes()

Overrides default org.eclipse.jetty.util.Attributes.clearAttributes.

Clear all attribute names
public boolean
consumeAvailable()

Implements org.eclipse.jetty.server.Request.consumeAvailable.

Consume any available content.
public void
demand(Runnable
the demand callback to invoke when there is a content chunk available.
demandCallback
)

Implements org.eclipse.jetty.server.Request.demand.

Demands to invoke the given demand callback parameter when a chunk of content is available.

public void
fail(Throwable
the cause of the failure
failure
)

Implements org.eclipse.jetty.io.Content.Source.fail.

Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.

public Object
getAttribute(String
the attribute to get
name
)

Implements org.eclipse.jetty.util.Attributes.getAttribute.

Get an attribute
public Set<String>
getAttributeNameSet()

Implements org.eclipse.jetty.util.Attributes.getAttributeNameSet.

Get the immutable set of attribute names.
public long
getBeginNanoTime()

Implements org.eclipse.jetty.server.Request.getBeginNanoTime.

Get the nanoTime at which the request arrived to a connector, obtained via System#nanoTime().

public Components
public ConnectionMetaData
public Context
getContext()

Implements org.eclipse.jetty.server.Request.getContext.

Get the Context associated with this Request.
public HttpFields
public long
getHeadersNanoTime()

Implements org.eclipse.jetty.server.Request.getHeadersNanoTime.

Get the nanoTime at which the request headers were parsed, obtained via System#nanoTime().

public HttpURI
public String
getId()

Implements org.eclipse.jetty.server.Request.getId.

an ID unique within the lifetime scope of the ConnectionMetaData#getId()).
public String
public HttpServletRequest
public Session
getSession(boolean
True if the session should be created for the request.
create
)

Implements org.eclipse.jetty.server.Request.getSession.

Get a Session associated with the request.

public HttpFields
public TunnelSupport
public boolean
public Content.Chunk
read()

Implements org.eclipse.jetty.server.Request.read.

Reads a chunk of content.

public Object
removeAttribute(String
the attribute to remove
name
)

Implements org.eclipse.jetty.util.Attributes.removeAttribute.

Remove an attribute
public Object
setAttribute(String
the attribute to set
name
,
Object
the value to set. A null value is equivalent to removing the attribute.
attribute
)

Implements org.eclipse.jetty.util.Attributes.setAttribute.

Set an attribute
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_httpFieldsback to summary
private final HttpFields _httpFields
_servletContextRequestback to summary
private final ServletContextRequest _servletContextRequest
_servletRequestback to summary
private final HttpServletRequest _servletRequest
_uriback to summary
private final HttpURI _uri

Constructor Detail

ServletCoreRequestback to summary
pack-priv ServletCoreRequest(HttpServletRequest request)

Method Detail

addFailureListenerback to summary
public void addFailureListener(Consumer<Throwable> onFailure)

Implements org.eclipse.jetty.server.Request.addFailureListener.

Doc from org.eclipse.jetty.server.Request.addFailureListener.

Adds a listener for asynchronous fatal failures.

When a listener is called, the effects of the failure have already taken place:

Listeners are processed in the same order they are added.

Parameters
onFailure:Consumer<Throwable>

the failure listener as a consumer function

Annotations
@Override
addHttpStreamWrapperback to summary
public void addHttpStreamWrapper(Function<HttpStream, HttpStream> wrapper)

Implements org.eclipse.jetty.server.Request.addHttpStreamWrapper.

Doc from org.eclipse.jetty.server.Request.addHttpStreamWrapper.

Add a HttpStream.Wrapper to the current HttpStream.

Parameters
wrapper:Function<HttpStream, HttpStream>

A function that wraps the passed stream.

Annotations
@Override
addIdleTimeoutListenerback to summary
public void addIdleTimeoutListener(Predicate<TimeoutException> onIdleTimeout)

Implements org.eclipse.jetty.server.Request.addIdleTimeoutListener.

Doc from org.eclipse.jetty.server.Request.addIdleTimeoutListener.

Adds a listener for idle timeouts.

The listener is a predicate function that should return true to indicate that the idle timeout should be handled by the container as a fatal failure (see addFailureListener(Consumer)); or false to ignore that specific timeout and for another timeout to occur after another idle period.

Idle timeout listeners are only invoked if there are no pending demand(Runnable) or Response#write(boolean, ByteBuffer, Callback) operations.

Listeners are processed in the same order they are added, and the first that returns true stops the processing of subsequent listeners, which are therefore not invoked.

Parameters
onIdleTimeout:Predicate<TimeoutException>

the idle timeout listener as a predicate function

Annotations
@Override
clearAttributesback to summary
public void clearAttributes()

Overrides default org.eclipse.jetty.util.Attributes.clearAttributes.

Doc from org.eclipse.jetty.util.Attributes.clearAttributes.

Clear all attribute names

Annotations
@Override
consumeAvailableback to summary
public boolean consumeAvailable()

Implements org.eclipse.jetty.server.Request.consumeAvailable.

Doc from org.eclipse.jetty.server.Request.consumeAvailable.

Consume any available content. This bypasses any request wrappers to process the content in Request#read() and reads directly from the HttpStream. This reads until there is no content currently available, or it reaches EOF. The HttpConfiguration#setMaxUnconsumedRequestContentReads(int) configuration can be used to configure how many reads will be attempted by this method.

Returns:boolean

true if the content was fully consumed.

Annotations
@Override
demandback to summary
public void demand(Runnable demandCallback)

Implements org.eclipse.jetty.server.Request.demand.

Doc from org.eclipse.jetty.server.Request.demand.

Demands to invoke the given demand callback parameter when a chunk of content is available.

See how to use this method idiomatically.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Runnable callback and a call to this method. Invocations of the passed Runnable are serialized and a callback for demand call is not invoked until any previous demand callback has returned. Thus the Runnable should not block waiting for a callback of a future demand call.

The demand callback may be invoked spuriously: a subsequent call to read() may return null.

Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.

Calling this method when there is already a pending demand results in an IllegalStateException to be thrown.

If the invocation of the demand callback throws an exception, then fail(Throwable) is called.

Parameters
demandCallback:Runnable

the demand callback to invoke when there is a content chunk available.

Annotations
@Override
failback to summary
public void fail(Throwable failure)

Implements org.eclipse.jetty.io.Content.Source.fail.

Doc from org.eclipse.jetty.io.Content.Source.fail.

Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.

The failure may be notified to the content reader at a later time, when the content reader reads a content chunk, via a Chunk instance with a non null Chunk#getFailure().

If read() has returned a last chunk, this is a no operation.

Typical failure: the content being aborted by user code, or idle timeouts.

If this method has already been called, then it is a no operation.

Parameters
failure:Throwable

the cause of the failure

Annotations
@Override
getAttributeback to summary
public Object getAttribute(String name)

Implements org.eclipse.jetty.util.Attributes.getAttribute.

Doc from org.eclipse.jetty.util.Attributes.getAttribute.

Get an attribute

Parameters
name:String

the attribute to get

Returns:Object

the value of the attribute

Annotations
@Override
getAttributeNameSetback to summary
public Set<String> getAttributeNameSet()

Implements org.eclipse.jetty.util.Attributes.getAttributeNameSet.

Doc from org.eclipse.jetty.util.Attributes.getAttributeNameSet.

Get the immutable set of attribute names.

Returns:Set<String>

Set of attribute names

Annotations
@Override
getBeginNanoTimeback to summary
public long getBeginNanoTime()

Implements org.eclipse.jetty.server.Request.getBeginNanoTime.

Doc from org.eclipse.jetty.server.Request.getBeginNanoTime.

Get the nanoTime at which the request arrived to a connector, obtained via System#nanoTime(). This method can be used when measuring latencies.

Returns:long

The nanoTime at which the request was received/created in nanoseconds

Annotations
@Override
getComponentsback to summary
public Components getComponents()

Implements org.eclipse.jetty.server.Request.getComponents.

Returns:Components

Doc from org.eclipse.jetty.server.Request.getComponents.

the Components to be used with this Request.

Annotations
@Override
getConnectionMetaDataback to summary
public ConnectionMetaData getConnectionMetaData()

Implements org.eclipse.jetty.server.Request.getConnectionMetaData.

Returns:ConnectionMetaData

Doc from org.eclipse.jetty.server.Request.getConnectionMetaData.

the ConnectionMetaData associated to this Request

Annotations
@Override
getContextback to summary
public Context getContext()

Implements org.eclipse.jetty.server.Request.getContext.

Doc from org.eclipse.jetty.server.Request.getContext.

Get the Context associated with this Request.

Note that a Request should always have an associated Context since if the Request is not being handled by a org.eclipse.jetty.server.handler.ContextHandler then the Context from Server#getContext() will be used.

Returns:Context

the Context associated with this Request. Never null.

Annotations
@Override
getHeadersback to summary
public HttpFields getHeaders()

Implements org.eclipse.jetty.server.Request.getHeaders.

Returns:HttpFields

Doc from org.eclipse.jetty.server.Request.getHeaders.

the HTTP headers of this Request

Annotations
@Override
getHeadersNanoTimeback to summary
public long getHeadersNanoTime()

Implements org.eclipse.jetty.server.Request.getHeadersNanoTime.

Doc from org.eclipse.jetty.server.Request.getHeadersNanoTime.

Get the nanoTime at which the request headers were parsed, obtained via System#nanoTime(). This method can be used when measuring latencies.

Returns:long

The nanoTime at which the request was ready in nanoseconds

Annotations
@Override
getHttpURIback to summary
public HttpURI getHttpURI()

Implements org.eclipse.jetty.server.Request.getHttpURI.

Returns:HttpURI

Doc from org.eclipse.jetty.server.Request.getHttpURI.

the HTTP URI of this Request

Annotations
@Override
getIdback to summary
public String getId()

Implements org.eclipse.jetty.server.Request.getId.

Doc from org.eclipse.jetty.server.Request.getId.

an ID unique within the lifetime scope of the ConnectionMetaData#getId()). This may be a protocol ID (e.g. HTTP/2 stream ID) or it may be unrelated to the protocol.

Annotations
@Override
getMethodback to summary
public String getMethod()

Implements org.eclipse.jetty.server.Request.getMethod.

Returns:String

Doc from org.eclipse.jetty.server.Request.getMethod.

the HTTP method of this Request

Annotations
@Override
getServletRequestback to summary
public HttpServletRequest getServletRequest()
getSessionback to summary
public Session getSession(boolean create)

Implements org.eclipse.jetty.server.Request.getSession.

Doc from org.eclipse.jetty.server.Request.getSession.

Get a Session associated with the request. Sessions may not be supported by a given configuration, in which case null will be returned.

Parameters
create:boolean

True if the session should be created for the request.

Returns:Session

The session associated with the request or null.

Annotations
@Override
getTrailersback to summary
public HttpFields getTrailers()

Implements org.eclipse.jetty.server.Request.getTrailers.

Returns:HttpFields

Doc from org.eclipse.jetty.server.Request.getTrailers.

the HTTP trailers of this Request, or null if they are not present

Annotations
@Override
getTunnelSupportback to summary
public TunnelSupport getTunnelSupport()

Implements org.eclipse.jetty.server.Request.getTunnelSupport.

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.eclipse.jetty.server.Request.isSecure.

Annotations
@Override
readback to summary
public Content.Chunk read()

Implements org.eclipse.jetty.server.Request.read.

Doc from org.eclipse.jetty.server.Request.read.

Reads a chunk of content.

See how to use this method idiomatically.

The returned chunk could be:

  • null, to signal that there isn't a chunk of content available
  • an Chunk instance with non null Chunk#getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has been failed externally
  • a Chunk instance, containing the chunk of content.

Once a read returns an Chunk instance with non-null Chunk#getFailure() then if the failure is last further reads will continue to return the same failure chunk instance, otherwise further read() operations may return different non-failure chunks.

Once a read returns a last chunk, further reads will continue to return a last chunk (although the instance may be different).

The content reader code must ultimately arrange for a call to Chunk#release() on the returned Chunk.

Additionally, prior to the ultimate call to Chunk#release(), the reader code may make additional calls to Chunk#retain(), that must ultimately be matched by a correspondent number of calls to Chunk#release().

Concurrent reads from different threads are not recommended, as they are inherently in a race condition.

Reads performed outside the invocation context of a demand callback are allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).

In addition, the returned Content.Chunk may be a Trailers instance, in case of request content trailers.

Returns:Content.Chunk

Doc from org.eclipse.jetty.io.Content.Source.read.

a chunk of content, possibly a failure instance, or null

Annotations
@Override
removeAttributeback to summary
public Object removeAttribute(String name)

Implements org.eclipse.jetty.util.Attributes.removeAttribute.

Doc from org.eclipse.jetty.util.Attributes.removeAttribute.

Remove an attribute

Parameters
name:String

the attribute to remove

Returns:Object

the value of the attribute if removed, else null

Annotations
@Override
setAttributeback to summary
public Object setAttribute(String name, Object attribute)

Implements org.eclipse.jetty.util.Attributes.setAttribute.

Doc from org.eclipse.jetty.util.Attributes.setAttribute.

Set an attribute

Parameters
name:String

the attribute to set

attribute:Object

the value to set. A null value is equivalent to removing the attribute.

Returns:Object

the previous value of the attribute if set, else null

Annotations
@Override