Package com.linecorp.armeria.common
Class DefaultHttpRequest
- java.lang.Object
-
- com.linecorp.armeria.common.stream.DefaultStreamMessage<HttpObject>
-
- com.linecorp.armeria.common.DefaultHttpRequest
-
- All Implemented Interfaces:
HttpRequest
,HttpRequestWriter
,Request
,StreamMessage<HttpObject>
,StreamWriter<HttpObject>
,org.reactivestreams.Publisher<HttpObject>
@Deprecated public class DefaultHttpRequest extends DefaultStreamMessage<HttpObject> implements HttpRequestWriter
Deprecated.DefaultHttpRequest
implementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultHttpRequest(RequestHeaders headers)
Deprecated.Creates a new instance with the specified headers.
-
Method Summary
Modifier and Type Method Description CompletableFuture<Void>
completionFuture()
Returns aCompletableFuture
that completes when this stream is complete, either successfully or exceptionally, including cancellation and abortion.protected EventExecutor
defaultSubscriberExecutor()
Returns the defaultEventExecutor
which will be used when a user subscribes usingStreamMessage.subscribe(Subscriber)
orStreamMessage.subscribe(Subscriber, SubscriptionOption...)
.CompletableFuture<List<T>>
drainAll()
Subscribes to thisStreamMessage
and retrieves all elements from it.CompletableFuture<List<T>>
drainAll(boolean withPooledObjects)
Subscribes to thisStreamMessage
and retrieves all elements from it.CompletableFuture<List<T>>
drainAll(SubscriptionOption... options)
Subscribes to thisStreamMessage
and retrieves all elements from it.CompletableFuture<List<T>>
drainAll(EventExecutor executor)
Subscribes to thisStreamMessage
and retrieves all elements from it.CompletableFuture<List<T>>
drainAll(EventExecutor executor, boolean withPooledObjects)
Subscribes to thisStreamMessage
and retrieves all elements from it.CompletableFuture<List<T>>
drainAll(EventExecutor executor, SubscriptionOption... options)
Subscribes to thisStreamMessage
and retrieves all elements from it.RequestHeaders
headers()
Deprecated.Returns the initial HTTP/2 headers of this request.CompletableFuture<Void>
onDemand(Runnable task)
Performs the specifiedtask
when there are enough demands from theSubscriber
.protected void
onRemoval(T obj)
Invoked after an element is removed from theStreamMessage
and beforeSubscriber.onNext(Object)
is invoked.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
Requests to start streaming data to the specifiedSubscriber
.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber, boolean withPooledObjects)
Requests to start streaming data to the specifiedSubscriber
.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber, SubscriptionOption... options)
Requests to start streaming data to the specifiedSubscriber
.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor)
Requests to start streaming data to the specifiedSubscriber
.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, boolean withPooledObjects)
Requests to start streaming data, invoking the specifiedSubscriber
from the specifiedExecutor
.void
subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, SubscriptionOption... options)
Requests to start streaming data to the specifiedSubscriber
.String
toString()
Deprecated.boolean
tryWrite(T obj)
Writes the specified object to theStreamMessage
.-
Methods inherited from class com.linecorp.armeria.common.stream.DefaultStreamMessage
abort, abort, close, close, isEmpty, isOpen, tryClose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.linecorp.armeria.common.HttpRequest
aggregate, aggregate, aggregateWithPooledObjects, aggregateWithPooledObjects, authority, contentType, method, path, scheme, uri, withHeaders, withHeaders
-
Methods inherited from interface com.linecorp.armeria.common.stream.StreamMessage
abort, abort, closeFuture, completionFuture, drainAll, drainAll, drainAll, drainAll, drainAll, drainAll, isComplete, isEmpty, isOpen, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe
-
-
-
-
Constructor Detail
-
DefaultHttpRequest
public DefaultHttpRequest(RequestHeaders headers)
Deprecated.Creates a new instance with the specified headers.
-
-
Method Detail
-
headers
public RequestHeaders headers()
Deprecated.Description copied from interface:HttpRequest
Returns the initial HTTP/2 headers of this request.- Specified by:
headers
in interfaceHttpRequest
-
tryWrite
public boolean tryWrite(T obj)
Description copied from interface:StreamWriter
Writes the specified object to theStreamMessage
. The written object will be transferred to theSubscriber
.- Specified by:
tryWrite
in interfaceStreamWriter<T>
- Returns:
true
if the specified object has been scheduled for publication.false
if the stream has been closed already.- See Also:
- Life cycle of reference-counted objects
-
onDemand
public CompletableFuture<Void> onDemand(Runnable task)
Description copied from interface:StreamWriter
Performs the specifiedtask
when there are enough demands from theSubscriber
.- Specified by:
onDemand
in interfaceStreamWriter<T>
- Returns:
- the future that completes successfully when the
task
finishes or exceptionally when theStreamMessage
is closed unexpectedly.
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber)
Description copied from interface:StreamMessage
Requests to start streaming data to the specifiedSubscriber
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<T>
- Specified by:
subscribe
in interfaceStreamMessage<T>
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, boolean withPooledObjects)
Description copied from interface:StreamMessage
Requests to start streaming data to the specifiedSubscriber
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceStreamMessage<T>
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, SubscriptionOption... options)
Description copied from interface:StreamMessage
Requests to start streaming data to the specifiedSubscriber
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceStreamMessage<T>
options
-SubscriptionOption
s to subscribe with
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, boolean withPooledObjects)
Description copied from interface:StreamMessage
Requests to start streaming data, invoking the specifiedSubscriber
from the specifiedExecutor
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceStreamMessage<T>
executor
- the executor to subscribe
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor)
Description copied from interface:StreamMessage
Requests to start streaming data to the specifiedSubscriber
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceStreamMessage<T>
executor
- the executor to subscribe
-
subscribe
public final void subscribe(org.reactivestreams.Subscriber<? super T> subscriber, EventExecutor executor, SubscriptionOption... options)
Description copied from interface:StreamMessage
Requests to start streaming data to the specifiedSubscriber
. If there is a problem subscribing,Subscriber.onError(Throwable)
will be invoked with one of the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.CancelledSubscriptionException
if this stream has been cancelled andSubscriptionOption.NOTIFY_CANCELLATION
is specified when subscribed.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
subscribe
in interfaceStreamMessage<T>
executor
- the executor to subscribeoptions
-SubscriptionOption
s to subscribe with
-
defaultSubscriberExecutor
protected EventExecutor defaultSubscriberExecutor()
Returns the defaultEventExecutor
which will be used when a user subscribes usingStreamMessage.subscribe(Subscriber)
orStreamMessage.subscribe(Subscriber, SubscriptionOption...)
.
-
drainAll
public final CompletableFuture<List<T>> drainAll()
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
drainAll
public final CompletableFuture<List<T>> drainAll(boolean withPooledObjects)
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
drainAll
public final CompletableFuture<List<T>> drainAll(SubscriptionOption... options)
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Parameters:
options
-SubscriptionOption
s to subscribe with. Note thatSubscriptionOption.NOTIFY_CANCELLATION
is ineffective because there's no cancelling while draining all elements.- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
drainAll
public final CompletableFuture<List<T>> drainAll(EventExecutor executor, boolean withPooledObjects)
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Parameters:
executor
- the executor to retrieve all elements- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
drainAll
public final CompletableFuture<List<T>> drainAll(EventExecutor executor)
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Parameters:
executor
- the executor to retrieve all elements- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
drainAll
public final CompletableFuture<List<T>> drainAll(EventExecutor executor, SubscriptionOption... options)
Description copied from interface:StreamMessage
Subscribes to thisStreamMessage
and retrieves all elements from it. The returnedCompletableFuture
may be completed exceptionally with the following exceptions:IllegalStateException
if otherSubscriber
subscribed to this stream already.AbortedStreamException
if this stream has been aborted.- Other exceptions that occurred due to an error while retrieving the elements.
- Specified by:
drainAll
in interfaceStreamMessage<T>
- Parameters:
executor
- the executor to retrieve all elementsoptions
-SubscriptionOption
s to subscribe with. Note thatSubscriptionOption.NOTIFY_CANCELLATION
is ineffective because there's no cancelling while draining all elements.- Returns:
- the
CompletableFuture
which will be completed with the list of the elements retrieved.
-
completionFuture
public final CompletableFuture<Void> completionFuture()
Description copied from interface:StreamMessage
Returns aCompletableFuture
that completes when this stream is complete, either successfully or exceptionally, including cancellation and abortion.A
StreamMessage
is complete (or 'fully consumed') when:- the
Subscriber
consumes all elements andSubscriber.onComplete()
is invoked, - an error occurred and
Subscriber.onError(Throwable)
is invoked, - the
Subscription
has been cancelled or StreamMessage.abort()
has been requested.
- Specified by:
completionFuture
in interfaceStreamMessage<T>
- the
-
onRemoval
protected void onRemoval(T obj)
Invoked after an element is removed from theStreamMessage
and beforeSubscriber.onNext(Object)
is invoked.- Parameters:
obj
- the removed element
-
-