public interface HttpResponse extends Response, StreamMessage<HttpObject>
Response.| Modifier and Type | Method and Description |
|---|---|
default CompletableFuture<AggregatedHttpResponse> |
aggregate()
Aggregates this response.
|
default CompletableFuture<AggregatedHttpResponse> |
aggregate(io.netty.util.concurrent.EventExecutor executor)
Aggregates this response.
|
default CompletableFuture<AggregatedHttpResponse> |
aggregateWithPooledObjects(io.netty.buffer.ByteBufAllocator alloc)
Aggregates this response.
|
default CompletableFuture<AggregatedHttpResponse> |
aggregateWithPooledObjects(io.netty.util.concurrent.EventExecutor executor,
io.netty.buffer.ByteBufAllocator alloc)
Aggregates this response.
|
default CompletableFuture<Void> |
closeFuture()
Deprecated.
|
default CompletableFuture<Void> |
completionFuture()
Deprecated.
|
static HttpResponse |
delayed(AggregatedHttpResponse response,
Duration delay)
Creates a new HTTP response that delegates to the provided
AggregatedHttpResponse, beginning
publishing after delay has passed from a random ScheduledExecutorService. |
static HttpResponse |
delayed(AggregatedHttpResponse response,
Duration delay,
ScheduledExecutorService executor)
Creates a new HTTP response that delegates to the provided
AggregatedHttpResponse, beginning
publishing after delay has passed from the provided ScheduledExecutorService. |
static HttpResponse |
delayed(HttpResponse response,
Duration delay)
Creates a new HTTP response that delegates to the provided
HttpResponse, beginning publishing
after delay has passed from a random ScheduledExecutorService. |
static HttpResponse |
delayed(HttpResponse response,
Duration delay,
ScheduledExecutorService executor)
Creates a new HTTP response that delegates to the provided
HttpResponse, beginning publishing
after delay has passed from the provided ScheduledExecutorService. |
static HttpResponse |
from(CompletionStage<? extends HttpResponse> stage)
Creates a new HTTP response that delegates to the
HttpResponse produced by the specified
CompletionStage. |
static HttpResponse |
from(CompletionStage<? extends HttpResponse> stage,
io.netty.util.concurrent.EventExecutor subscriberExecutor)
Creates a new HTTP response that delegates to the
HttpResponse produced by the specified
CompletionStage. |
static HttpResponse |
of(AggregatedHttpResponse res)
Deprecated.
|
static HttpResponse |
of(HttpObject... objs)
Creates a new HTTP response of the specified objects.
|
static HttpResponse |
of(HttpStatus status)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
byte[] content)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
CharSequence content)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
HttpData content)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
HttpData content,
HttpHeaders trailers)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
String content)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(HttpStatus status,
MediaType mediaType,
String format,
Object... args)
Creates a new HTTP response of the specified
HttpStatus. |
static HttpResponse |
of(int statusCode)
Creates a new HTTP response of the specified
statusCode. |
static HttpResponse |
of(MediaType mediaType,
String content)
Creates a new HTTP response of OK status with the content.
|
static HttpResponse |
of(MediaType mediaType,
String format,
Object... args)
Creates a new HTTP response of OK status with the content.
|
static HttpResponse |
of(org.reactivestreams.Publisher<? extends HttpObject> publisher)
Creates a new HTTP response whose stream is produced from an existing
Publisher. |
static HttpResponse |
of(ResponseHeaders headers)
Creates a new HTTP response of the specified headers.
|
static HttpResponse |
of(ResponseHeaders headers,
HttpData content)
Creates a new HTTP response of the specified headers and content.
|
static HttpResponse |
of(ResponseHeaders headers,
HttpData content,
HttpHeaders trailers)
Creates a new HTTP response of the specified objects.
|
static HttpResponse |
of(String content)
Creates a new HTTP response of OK status with the content as UTF_8.
|
static HttpResponse |
of(String format,
Object... args)
Creates a new HTTP response of OK status with the content as UTF_8.
|
static HttpResponse |
ofFailed(Throwable cause)
Deprecated.
Use
ofFailure(Throwable). |
static HttpResponse |
ofFailure(Throwable cause)
Creates a new failed HTTP response.
|
static HttpResponseWriter |
streaming()
Creates a new HTTP response that can stream an arbitrary number of
HttpObject to the client. |
default HttpResponseDuplicator |
toDuplicator()
Returns a new
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements. |
default HttpResponseDuplicator |
toDuplicator(io.netty.util.concurrent.EventExecutor executor)
Returns a new
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements. |
default HttpResponseDuplicator |
toDuplicator(io.netty.util.concurrent.EventExecutor executor,
long maxResponseLength)
Returns a new
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements. |
default HttpResponseDuplicator |
toDuplicator(long maxResponseLength)
Returns a new
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements. |
CompletableFuture<Void> |
whenComplete()
Returns a
CompletableFuture which completes when
1) the response stream has been closed (the StreamMessage has been completed) or
2) the result value is set (the CompletionStage has completed.) |
static HttpResponseWriter streaming()
HttpObject to the client.
The first object written must be of type ResponseHeaders.static HttpResponse from(CompletionStage<? extends HttpResponse> stage)
HttpResponse produced by the specified
CompletionStage. If the specified CompletionStage fails, the returned response will be
closed with the same cause as well.stage - the CompletionStage which will produce the actual HttpResponsestatic HttpResponse from(CompletionStage<? extends HttpResponse> stage, io.netty.util.concurrent.EventExecutor subscriberExecutor)
HttpResponse produced by the specified
CompletionStage. If the specified CompletionStage fails, the returned response will be
closed with the same cause as well.stage - the CompletionStage which will produce the actual HttpResponsesubscriberExecutor - the EventExecutor which will be used when a user subscribes
the returned HttpResponse using StreamMessage.subscribe(Subscriber)
or StreamMessage.subscribe(Subscriber, SubscriptionOption...).static HttpResponse delayed(AggregatedHttpResponse response, Duration delay)
AggregatedHttpResponse, beginning
publishing after delay has passed from a random ScheduledExecutorService.static HttpResponse delayed(AggregatedHttpResponse response, Duration delay, ScheduledExecutorService executor)
AggregatedHttpResponse, beginning
publishing after delay has passed from the provided ScheduledExecutorService.static HttpResponse delayed(HttpResponse response, Duration delay)
HttpResponse, beginning publishing
after delay has passed from a random ScheduledExecutorService.static HttpResponse delayed(HttpResponse response, Duration delay, ScheduledExecutorService executor)
HttpResponse, beginning publishing
after delay has passed from the provided ScheduledExecutorService.static HttpResponse of(int statusCode)
statusCode.of in interface StreamMessage<HttpObject>IllegalArgumentException - if the HttpStatusClass is
informational (1xx).static HttpResponse of(HttpStatus status)
HttpStatus.of in interface StreamMessage<HttpObject>IllegalArgumentException - if the HttpStatusClass is
informational (1xx).static HttpResponse of(HttpStatus status, MediaType mediaType, CharSequence content)
HttpStatus.mediaType - the MediaType of the response contentcontent - the content of the responsestatic HttpResponse of(HttpStatus status, MediaType mediaType, String content)
HttpStatus.mediaType - the MediaType of the response contentcontent - the content of the responsestatic HttpResponse of(String content)
of in interface StreamMessage<HttpObject>content - the content of the responsestatic HttpResponse of(String format, Object... args)
String.format(Locale, String, Object...) with
English locale.of in interface StreamMessage<HttpObject>format - the format string of the response contentargs - the arguments referenced by the format specifiers in the format stringstatic HttpResponse of(MediaType mediaType, String content)
of in interface StreamMessage<HttpObject>mediaType - the MediaType of the response contentcontent - the content of the responsestatic HttpResponse of(MediaType mediaType, String format, Object... args)
String.format(Locale, String, Object...) with
English locale.mediaType - the MediaType of the response contentformat - the format string of the response contentargs - the arguments referenced by the format specifiers in the format stringstatic HttpResponse of(HttpStatus status, MediaType mediaType, String format, Object... args)
HttpStatus.
The content of the response is formatted by String.format(Locale, String, Object...) with
English locale.mediaType - the MediaType of the response contentformat - the format string of the response contentargs - the arguments referenced by the format specifiers in the format stringstatic HttpResponse of(HttpStatus status, MediaType mediaType, byte[] content)
HttpStatus. The content will be wrapped
using HttpData.wrap(byte[]), so any changes made to content will be reflected in the
response.mediaType - the MediaType of the response contentcontent - the content of the responsestatic HttpResponse of(HttpStatus status, MediaType mediaType, HttpData content)
HttpStatus.mediaType - the MediaType of the response contentcontent - the content of the responsestatic HttpResponse of(HttpStatus status, MediaType mediaType, HttpData content, HttpHeaders trailers)
HttpStatus.mediaType - the MediaType of the response contentcontent - the content of the responsetrailers - the HTTP trailersstatic HttpResponse of(ResponseHeaders headers)
of in interface StreamMessage<HttpObject>static HttpResponse of(ResponseHeaders headers, HttpData content)
of in interface StreamMessage<HttpObject>static HttpResponse of(ResponseHeaders headers, HttpData content, HttpHeaders trailers)
static HttpResponse of(HttpObject... objs)
of in interface StreamMessage<HttpObject>@Deprecated static HttpResponse of(AggregatedHttpResponse res)
AggregatedHttpResponse.toHttpResponse().AggregatedHttpResponse into a new complete HttpResponse.of in interface StreamMessage<HttpObject>static HttpResponse of(org.reactivestreams.Publisher<? extends HttpObject> publisher)
Publisher.of in interface StreamMessage<HttpObject>static HttpResponse ofFailure(Throwable cause)
@Deprecated static HttpResponse ofFailed(Throwable cause)
ofFailure(Throwable).@Deprecated default CompletableFuture<Void> closeFuture()
ResponseCompletableFuture which completes when
1) the response stream has been closed (the StreamMessage has been completed) or
2) the result value is set (the CompletionStage has completed.)closeFuture in interface ResponsecloseFuture in interface StreamMessage<HttpObject>@Deprecated default CompletableFuture<Void> completionFuture()
ResponseCompletableFuture which completes when
1) the response stream has been closed (the StreamMessage has been completed) or
2) the result value is set (the CompletionStage has completed.)completionFuture in interface ResponsecompletionFuture in interface StreamMessage<HttpObject>CompletableFuture<Void> whenComplete()
ResponseCompletableFuture which completes when
1) the response stream has been closed (the StreamMessage has been completed) or
2) the result value is set (the CompletionStage has completed.)whenComplete in interface ResponsewhenComplete in interface StreamMessage<HttpObject>default CompletableFuture<AggregatedHttpResponse> aggregate()
CompletableFuture will be notified when the content and
the trailers of the response are received fully.default CompletableFuture<AggregatedHttpResponse> aggregate(io.netty.util.concurrent.EventExecutor executor)
CompletableFuture will be notified when the content and
the trailers of the response are received fully.default CompletableFuture<AggregatedHttpResponse> aggregateWithPooledObjects(io.netty.buffer.ByteBufAllocator alloc)
CompletableFuture will be notified when the content and
the trailers of the response are received fully. AggregatedHttpMessage.content() will
return a pooled object, and the caller must ensure to release it. If you don't know what this means,
use aggregate().default CompletableFuture<AggregatedHttpResponse> aggregateWithPooledObjects(io.netty.util.concurrent.EventExecutor executor, io.netty.buffer.ByteBufAllocator alloc)
CompletableFuture will be notified when the content and
the trailers of the request is received fully. AggregatedHttpMessage.content() will
return a pooled object, and the caller must ensure to release it. If you don't know what this means,
use aggregate().default HttpResponseDuplicator toDuplicator()
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements.
Note that you cannot subscribe to this HttpResponse anymore after you call this method.
To subscribe, call HttpResponseDuplicator.duplicate() from the returned
HttpResponseDuplicator.toDuplicator in interface StreamMessage<HttpObject>default HttpResponseDuplicator toDuplicator(io.netty.util.concurrent.EventExecutor executor)
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements.
Note that you cannot subscribe to this HttpResponse anymore after you call this method.
To subscribe, call HttpResponseDuplicator.duplicate() from the returned
HttpResponseDuplicator.toDuplicator in interface StreamMessage<HttpObject>executor - the executor to duplicatedefault HttpResponseDuplicator toDuplicator(long maxResponseLength)
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements.
Note that you cannot subscribe to this HttpResponse anymore after you call this method.
To subscribe, call HttpResponseDuplicator.duplicate() from the returned
HttpResponseDuplicator.maxResponseLength - the maximum response length that the duplicator can hold in its buffer.
ContentTooLargeException is raised if the length of the buffered
HttpData is greater than this value.default HttpResponseDuplicator toDuplicator(io.netty.util.concurrent.EventExecutor executor, long maxResponseLength)
HttpResponseDuplicator that duplicates this HttpResponse into one or
more HttpResponses, which publish the same elements.
Note that you cannot subscribe to this HttpResponse anymore after you call this method.
To subscribe, call HttpResponseDuplicator.duplicate() from the returned
HttpResponseDuplicator.executor - the executor to duplicatemaxResponseLength - the maximum response length that the duplicator can hold in its buffer.
ContentTooLargeException is raised if the length of the buffered
HttpData is greater than this value.Copyright © 2020 LeanCloud. All rights reserved.