public interface HttpRequest extends Request, StreamMessage<HttpObject>
Request.
Note: The initial RequestHeaders is not signaled to Subscribers. It is readily available
via headers().
| Modifier and Type | Method and Description |
|---|---|
default CompletableFuture<AggregatedHttpRequest> |
aggregate()
Aggregates this request.
|
default CompletableFuture<AggregatedHttpRequest> |
aggregate(io.netty.util.concurrent.EventExecutor executor)
Aggregates this request.
|
default CompletableFuture<AggregatedHttpRequest> |
aggregateWithPooledObjects(io.netty.buffer.ByteBufAllocator alloc)
Aggregates this request.
|
default CompletableFuture<AggregatedHttpRequest> |
aggregateWithPooledObjects(io.netty.util.concurrent.EventExecutor executor,
io.netty.buffer.ByteBufAllocator alloc)
Aggregates this request.
|
default String |
authority()
Returns the authority of this request.
|
default MediaType |
contentType()
Returns the value of the
'content-type' header. |
RequestHeaders |
headers()
Returns the initial HTTP/2 headers of this request.
|
default HttpMethod |
method()
Returns the method of this request.
|
static HttpRequest |
of(AggregatedHttpRequest request)
Deprecated.
|
static HttpRequest |
of(HttpMethod method,
String path)
Creates a new HTTP request with empty content and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
byte[] content)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
CharSequence content)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
HttpData content)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
HttpData content,
HttpHeaders trailers)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
String content)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpMethod method,
String path,
MediaType mediaType,
String format,
Object... args)
Creates a new HTTP request and closes the stream.
|
static HttpRequest |
of(HttpRequest request,
RequestHeaders newHeaders)
Deprecated.
|
static HttpRequest |
of(RequestHeaders headers)
Creates a new
HttpRequest with empty content and closes the stream. |
static HttpRequest |
of(RequestHeaders headers,
HttpData... contents)
Creates a new
HttpRequest that publishes the given HttpObjects and closes the stream. |
static HttpRequest |
of(RequestHeaders headers,
HttpData content)
Creates a new
HttpRequest and closes the stream. |
static HttpRequest |
of(RequestHeaders headers,
HttpData content,
HttpHeaders trailers)
Creates a new
HttpRequest and closes the stream. |
static HttpRequest |
of(RequestHeaders headers,
org.reactivestreams.Publisher<? extends HttpObject> publisher)
Creates a new instance from an existing
RequestHeaders and Publisher. |
default String |
path()
Returns the path of this request.
|
default String |
scheme()
Returns the scheme of this request.
|
static HttpRequestWriter |
streaming(HttpMethod method,
String path)
Creates a new HTTP request that can be used to stream an arbitrary number of
HttpObject
with the initial RequestHeaders of the specified HttpMethod and path. |
static HttpRequestWriter |
streaming(RequestHeaders headers)
Creates a new HTTP request that can be used to stream an arbitrary number of
HttpObject
with the specified initial RequestHeaders. |
default HttpRequestDuplicator |
toDuplicator()
Returns a new
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements. |
default HttpRequestDuplicator |
toDuplicator(io.netty.util.concurrent.EventExecutor executor)
Returns a new
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements. |
default HttpRequestDuplicator |
toDuplicator(io.netty.util.concurrent.EventExecutor executor,
long maxRequestLength)
Returns a new
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements. |
default HttpRequestDuplicator |
toDuplicator(long maxRequestLength)
Returns a new
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements. |
default URI |
uri()
Returns the URI of this request.
|
default HttpRequest |
withHeaders(RequestHeaders newHeaders)
Returns a new
HttpRequest derived from this HttpRequest by replacing its
RequestHeaders with the specified newHeaders. |
default HttpRequest |
withHeaders(RequestHeadersBuilder newHeadersBuilder)
Returns a new
HttpRequest derived from this HttpRequest by replacing its
RequestHeaders with what's built from the specified newHeadersBuilder. |
abort, abort, closeFuture, completionFuture, defaultSubscriberExecutor, drainAll, drainAll, drainAll, drainAll, isComplete, isEmpty, isOpen, of, subscribe, subscribe, subscribe, subscribe, whenCompletestatic HttpRequestWriter streaming(HttpMethod method, String path)
HttpObject
with the initial RequestHeaders of the specified HttpMethod and path.static HttpRequestWriter streaming(RequestHeaders headers)
HttpObject
with the specified initial RequestHeaders.static HttpRequest of(HttpMethod method, String path)
of in interface StreamMessage<HttpObject>method - the HTTP method of the requestpath - the path of the requeststatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, CharSequence content)
method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentcontent - the content of the requeststatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, String content)
method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentcontent - the content of the requeststatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, String format, Object... args)
String.format(Locale, String, Object...) with English locale.method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentformat - the format string of the request contentargs - the arguments referenced by the format specifiers in the format stringstatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, byte[] content)
content will be wrapped using
HttpData.wrap(byte[]), so any changes made to content will be reflected in the request.method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentcontent - the content of the requeststatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, HttpData content)
method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentcontent - the content of the requeststatic HttpRequest of(HttpMethod method, String path, MediaType mediaType, HttpData content, HttpHeaders trailers)
method - the HTTP method of the requestpath - the path of the requestmediaType - the MediaType of the request contentcontent - the content of the requesttrailers - the HTTP trailersstatic HttpRequest of(RequestHeaders headers)
HttpRequest with empty content and closes the stream.of in interface StreamMessage<HttpObject>static HttpRequest of(RequestHeaders headers, HttpData content)
HttpRequest and closes the stream.of in interface StreamMessage<HttpObject>static HttpRequest of(RequestHeaders headers, HttpData content, HttpHeaders trailers)
HttpRequest and closes the stream.IllegalStateException - if the headers are malformed.static HttpRequest of(RequestHeaders headers, HttpData... contents)
HttpRequest that publishes the given HttpObjects and closes the stream.of in interface StreamMessage<HttpObject>@Deprecated static HttpRequest of(AggregatedHttpRequest request)
AggregatedHttpRequest.toHttpRequest().AggregatedHttpRequest into a new complete HttpRequest.of in interface StreamMessage<HttpObject>static HttpRequest of(RequestHeaders headers, org.reactivestreams.Publisher<? extends HttpObject> publisher)
RequestHeaders and Publisher.of in interface StreamMessage<HttpObject>@Deprecated static HttpRequest of(HttpRequest request, RequestHeaders newHeaders)
withHeaders(RequestHeaders) or withHeaders(RequestHeadersBuilder).HttpRequest derived from an existing HttpRequest by replacing its
RequestHeaders with the specified newHeaders. Note that the content stream and trailers
of the specified HttpRequest is not duplicated, which means you can subscribe to only one of
the two HttpRequests.
If you are using this method for intercepting an HttpRequest in a decorator, make sure to
update RequestContext.request() with RequestContext.updateRequest(HttpRequest), e.g.
> public class MyService extends SimpleDecoratingHttpService {
> @Override
> public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) {
> // Create a new request with an additional header.
> final HttpRequest newReq =
> HttpRequest.of(req,
> req.headers().toBuilder()
> .set("x-custom-header", "value")
> .build());
>
> // Update the ctx.request.
> ctx.updateRequest(newReq);
>
> // Delegate the new request with the updated context.
> return delegate().serve(ctx, newReq);
> }
> }
of in interface StreamMessage<HttpObject>RequestHeaders headers()
default URI uri()
headers().uri().default String scheme()
headers().scheme().default HttpMethod method()
headers().method().default String path()
headers().path().default String authority()
headers().authority().default MediaType contentType()
'content-type' header.null otherwise.default HttpRequest withHeaders(RequestHeaders newHeaders)
HttpRequest derived from this HttpRequest by replacing its
RequestHeaders with the specified newHeaders. Note that the content stream and trailers
of this HttpRequest is not duplicated, which means you can subscribe to only one of the two
HttpRequests.
If you are using this method for intercepting an HttpRequest in a decorator, make sure to
update RequestContext.request() with RequestContext.updateRequest(HttpRequest), e.g.
> public class MyService extends SimpleDecoratingHttpService {
> @Override
> public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) {
> // Create a new request with an additional header.
> final HttpRequest newReq =
> req.withHeaders(req.headers().toBuilder()
> .set("x-custom-header", "value")
> .build());
>
> // Update the ctx.request.
> ctx.updateRequest(newReq);
>
> // Delegate the new request with the updated context.
> return delegate().serve(ctx, newReq);
> }
> }
default HttpRequest withHeaders(RequestHeadersBuilder newHeadersBuilder)
HttpRequest derived from this HttpRequest by replacing its
RequestHeaders with what's built from the specified newHeadersBuilder.
Note that the content stream and trailers of this HttpRequest is not duplicated,
which means you can subscribe to only one of the two HttpRequests.
If you are using this method for intercepting an HttpRequest in a decorator, make sure to
update RequestContext.request() with RequestContext.updateRequest(HttpRequest), e.g.
> public class MyService extends SimpleDecoratingHttpService {
> @Override
> public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) {
> // Create a new request with an additional header.
> final HttpRequest newReq =
> req.withHeaders(req.headers().toBuilder()
> .set("x-custom-header", "value"));
>
> // Update the ctx.request.
> ctx.updateRequest(newReq);
>
> // Delegate the new request with the updated context.
> return delegate().serve(ctx, newReq);
> }
> }
default CompletableFuture<AggregatedHttpRequest> aggregate()
CompletableFuture will be notified when the content and
the trailers of the request is received fully.default CompletableFuture<AggregatedHttpRequest> aggregate(io.netty.util.concurrent.EventExecutor executor)
CompletableFuture will be notified when the content and
the trailers of the request is received fully.default CompletableFuture<AggregatedHttpRequest> aggregateWithPooledObjects(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 CompletableFuture<AggregatedHttpRequest> 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 HttpRequestDuplicator toDuplicator()
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements.
Note that you cannot subscribe to this HttpRequest anymore after you call this method.
To subscribe, call HttpRequestDuplicator.duplicate() from the returned
HttpRequestDuplicator.toDuplicator in interface StreamMessage<HttpObject>default HttpRequestDuplicator toDuplicator(io.netty.util.concurrent.EventExecutor executor)
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements.
Note that you cannot subscribe to this HttpRequest anymore after you call this method.
To subscribe, call HttpRequestDuplicator.duplicate() from the returned
HttpRequestDuplicator.toDuplicator in interface StreamMessage<HttpObject>executor - the executor to duplicatedefault HttpRequestDuplicator toDuplicator(long maxRequestLength)
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements.
Note that you cannot subscribe to this HttpRequest anymore after you call this method.
To subscribe, call HttpRequestDuplicator.duplicate() from the returned
HttpRequestDuplicator.maxRequestLength - the maximum request 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 HttpRequestDuplicator toDuplicator(io.netty.util.concurrent.EventExecutor executor, long maxRequestLength)
HttpRequestDuplicator that duplicates this HttpRequest into one or
more HttpRequests, which publish the same elements.
Note that you cannot subscribe to this HttpRequest anymore after you call this method.
To subscribe, call HttpRequestDuplicator.duplicate() from the returned
HttpRequestDuplicator.executor - the executor to duplicatemaxRequestLength - the maximum request 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.