Top Description Inners Fields Methods
org.eclipse.jetty.server

public Interface HttpStream

extends Callback
Known Direct Implementers
org.eclipse.jetty.server.HttpStream.Wrapper, org.eclipse.jetty.server.internal.HttpConnection.HttpStreamOverHTTP1
Imports
java.nio.ByteBuffer, org.eclipse.jetty.http.HttpFields, .MetaData, org.eclipse.jetty.io.Connection, .Content, .Content.Chunk, org.eclipse.jetty.util.Callback, .StaticException

A HttpStream is an abstraction that together with MetaData.Request, represents the flow of data from and to a single request and response cycle. It is roughly analogous to the Stream within an HTTP/2 connection, in that a connection can have many streams, each used once and each representing a single request and response exchange.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final Exception
public static final String
UPGRADE_CONNECTION_ATTRIBUTE

Attribute name to be used as a Request attribute to store/retrieve the Connection created during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.

Inherited from org.eclipse.jetty.util.Callback:
NOOP

Method Summary

Modifier and TypeMethod and Description
public Throwable
public static Throwable
public void
demand()

Demands more content chunks to the underlying implementation.

public String
getId()

Returns: an ID unique within the lifetime scope of the associated protocol connection.

public long
public default TunnelSupport
public boolean
public void
prepareResponse(HttpFields.Mutable
The headers to prepare.
headers
)

Prepare the response headers with respect to the stream.

public default void
push(MetaData.Request
the resource to push
resource
)

Pushes the given resource to the client.

public Content.Chunk

Returns:

a chunk of content, possibly with non-null Chunk#getFailure() or null.
read
()

Reads a chunk of content, with the same semantic as Content.Source#read().

public void
send(MetaData.Request
The request metadata for which the response should be sent.
request
,
MetaData.Response
The response metadata to be sent or null if the response is already committed by a previous call to send.
response
,
boolean
True if this will be the last call to send and the response can be completed.
last
,
ByteBuffer
A buffer of content to send or null if no content.
content
,
Callback
The callback to invoke when the send is completed successfully or in failure.
callback
)

Send response meta-data and/or data.

public void
setIdleTimeout(long idleTimeoutMs)

Inherited from org.eclipse.jetty.util.Callback:
combinecompleteWithfailedfromfromfromfromfromfromfromfromfromfromfromsucceeded

Field Detail

CONTENT_NOT_CONSUMEDback to summary
public static final Exception CONTENT_NOT_CONSUMED
UPGRADE_CONNECTION_ATTRIBUTEback to summary
public static final String UPGRADE_CONNECTION_ATTRIBUTE

Attribute name to be used as a Request attribute to store/retrieve the Connection created during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.

Method Detail

consumeAvailableback to summary
public Throwable consumeAvailable()
consumeAvailableback to summary
public static Throwable consumeAvailable(HttpStream stream, HttpConfiguration httpConfig)
demandback to summary
public void demand()

Demands more content chunks to the underlying implementation.

This method is called from the implementation of Request#demand(Runnable) and when the demand can be satisfied the implementation must call HttpChannel#onContentAvailable(). If there is a problem meeting demand, then the implementation must call HttpChannel#onFailure(Throwable).

See Also
HttpChannel#onContentAvailable(), HttpChannel#onFailure(Throwable)
getIdback to summary
public String getId()
Returns:String

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

getIdleTimeoutback to summary
public long getIdleTimeout()
getTunnelSupportback to summary
public default TunnelSupport getTunnelSupport()
isCommittedback to summary
public boolean isCommitted()
prepareResponseback to summary
public void prepareResponse(HttpFields.Mutable headers)

Prepare the response headers with respect to the stream. Typically this may set headers related to protocol specific behaviour (e.g. Keep-Alive for HTTP/1.0 connections).

Parameters
headers:HttpFields.Mutable

The headers to prepare.

pushback to summary
public default void push(MetaData.Request resource)

Pushes the given resource to the client.

Parameters
resource:MetaData.Request

the resource to push

Exceptions
UnsupportedOperationException:
if the push functionality is not supported
See Also
ConnectionMetaData#isPushSupported()
readback to summary
public Content.Chunk read()

Reads a chunk of content, with the same semantic as Content.Source#read().

This method is called from the implementation of Request#read().

Returns:Content.Chunk

a chunk of content, possibly with non-null Chunk#getFailure() or null.

sendback to summary
public void send(MetaData.Request request, MetaData.Response response, boolean last, ByteBuffer content, Callback callback)

Send response meta-data and/or data.

Parameters
request:MetaData.Request

The request metadata for which the response should be sent.

response:MetaData.Response

The response metadata to be sent or null if the response is already committed by a previous call to send.

last:boolean

True if this will be the last call to send and the response can be completed.

content:ByteBuffer

A buffer of content to send or null if no content.

callback:Callback

The callback to invoke when the send is completed successfully or in failure.

setIdleTimeoutback to summary
public void setIdleTimeout(long idleTimeoutMs)
org.eclipse.jetty.server back to summary

public Class HttpStream.Wrapper

extends Object
implements HttpStream
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.HttpStream, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.thread.Invocable
Known Direct Subclasses
org.eclipse.jetty.server.internal.CompletionStreamWrapper

Field Summary

Modifier and TypeField and Description
private final HttpStream

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final Throwable
public void
demand()

Implements org.eclipse.jetty.server.HttpStream.demand.

Demands more content chunks to the underlying implementation.

public void
failed(Throwable
the reason for the operation failure
x
)

Overrides default org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

public final String
public long
public Invocable.InvocationType
public TunnelSupport
public HttpStream
public final boolean
public void
prepareResponse(HttpFields.Mutable
The headers to prepare.
headers
)

Implements org.eclipse.jetty.server.HttpStream.prepareResponse.

Prepare the response headers with respect to the stream.

public void
push(MetaData.Request
the resource to push
resource
)

Overrides default org.eclipse.jetty.server.HttpStream.push.

Pushes the given resource to the client.

public Content.Chunk
read()

Implements org.eclipse.jetty.server.HttpStream.read.

Reads a chunk of content, with the same semantic as Content.Source#read().

public void
send(MetaData.Request
The request metadata for which the response should be sent.
request
,
MetaData.Response
The response metadata to be sent or null if the response is already committed by a previous call to send.
response
,
boolean
True if this will be the last call to send and the response can be completed.
last
,
ByteBuffer
A buffer of content to send or null if no content.
content
,
Callback
The callback to invoke when the send is completed successfully or in failure.
callback
)

Implements org.eclipse.jetty.server.HttpStream.send.

Send response meta-data and/or data.

public void
public void
succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_wrappedback to summary
private final HttpStream _wrapped

Constructor Detail

Wrapperback to summary
public Wrapper(HttpStream wrapped)

Method Detail

consumeAvailableback to summary
public final Throwable consumeAvailable()

Implements org.eclipse.jetty.server.HttpStream.consumeAvailable.

Annotations
@Override
demandback to summary
public void demand()

Implements org.eclipse.jetty.server.HttpStream.demand.

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

Demands more content chunks to the underlying implementation.

This method is called from the implementation of Request#demand(Runnable) and when the demand can be satisfied the implementation must call HttpChannel#onContentAvailable(). If there is a problem meeting demand, then the implementation must call HttpChannel#onFailure(Throwable).

Annotations
@Override
failedback to summary
public void failed(Throwable x)

Overrides default org.eclipse.jetty.util.Callback.failed.

Doc from org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

Parameters
x:Throwable

the reason for the operation failure

Annotations
@Override
getIdback to summary
public final String getId()

Implements org.eclipse.jetty.server.HttpStream.getId.

Returns:String

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

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

Annotations
@Override
getIdleTimeoutback to summary
public long getIdleTimeout()

Implements org.eclipse.jetty.server.HttpStream.getIdleTimeout.

Annotations
@Override
getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Override
getTunnelSupportback to summary
public TunnelSupport getTunnelSupport()

Overrides default org.eclipse.jetty.server.HttpStream.getTunnelSupport.

Annotations
@Override
getWrappedback to summary
public HttpStream getWrapped()
isCommittedback to summary
public final boolean isCommitted()

Implements org.eclipse.jetty.server.HttpStream.isCommitted.

Annotations
@Override
prepareResponseback to summary
public void prepareResponse(HttpFields.Mutable headers)

Implements org.eclipse.jetty.server.HttpStream.prepareResponse.

Doc from org.eclipse.jetty.server.HttpStream.prepareResponse.

Prepare the response headers with respect to the stream. Typically this may set headers related to protocol specific behaviour (e.g. Keep-Alive for HTTP/1.0 connections).

Parameters
headers:HttpFields.Mutable

The headers to prepare.

Annotations
@Override
pushback to summary
public void push(MetaData.Request resource)

Overrides default org.eclipse.jetty.server.HttpStream.push.

Doc from org.eclipse.jetty.server.HttpStream.push.

Pushes the given resource to the client.

Parameters
resource:MetaData.Request

the resource to push

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

Implements org.eclipse.jetty.server.HttpStream.read.

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

Reads a chunk of content, with the same semantic as Content.Source#read().

This method is called from the implementation of Request#read().

Returns:Content.Chunk

a chunk of content, possibly with non-null Chunk#getFailure() or null.

Annotations
@Override
sendback to summary
public void send(MetaData.Request request, MetaData.Response response, boolean last, ByteBuffer content, Callback callback)

Implements org.eclipse.jetty.server.HttpStream.send.

Doc from org.eclipse.jetty.server.HttpStream.send.

Send response meta-data and/or data.

Parameters
request:MetaData.Request

The request metadata for which the response should be sent.

response:MetaData.Response

The response metadata to be sent or null if the response is already committed by a previous call to send.

last:boolean

True if this will be the last call to send and the response can be completed.

content:ByteBuffer

A buffer of content to send or null if no content.

callback:Callback

The callback to invoke when the send is completed successfully or in failure.

Annotations
@Override
setIdleTimeoutback to summary
public void setIdleTimeout(long idleTimeoutMs)

Implements org.eclipse.jetty.server.HttpStream.setIdleTimeout.

Annotations
@Override
succeededback to summary
public void succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Doc from org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Annotations
@Override