Class HttpClientRequest
- java.lang.Object
-
- io.vertx.mutiny.core.http.HttpClientRequest
-
- All Implemented Interfaces:
ReadStream<HttpClientResponse>,StreamBase,WriteStream<Buffer>
public class HttpClientRequest extends Object implements WriteStream<Buffer>, ReadStream<HttpClientResponse>
Represents a client-side HTTP request.Instances are created by an
HttpClientinstance, via one of the methods corresponding to the specific HTTP methods, or the generic request methods. On creation the request will not have been written to the wire.Once a request has been obtained, headers can be set on it, and data can be written to its body if required. Once you are ready to send the request, one of the
end(java.lang.String)methods should be called.Nothing is actually sent until the request has been internally assigned an HTTP connection.
The
HttpClientinstance will return an instance of this class immediately, even if there are no HTTP connections available in the pool. Any requests sent before a connection is assigned will be queued internally and actually sent when an HTTP connection becomes available from the pool.The headers of the request are queued for writing either when the
end(java.lang.String)method is called, or, when the first part of the body is written, whichever occurs first.This class supports both chunked and non-chunked HTTP.
It implements
WriteStreamso it can be used withPumpto pump data with flow control.An example of using this class is as follows:
NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpClientRequest>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpClientRequest(io.vertx.core.http.HttpClientRequest delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringabsoluteURI()HttpConnectionconnection()HttpClientRequestconnectionHandler(Consumer<HttpConnection> handler)Deprecated.HttpClientRequestcontinueHandler(Consumer<Void> handler)HttpClientRequestdrainHandler(Consumer<Void> handler)io.smallrye.mutiny.Uni<Void>end()Same asend(java.lang.String)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(Buffer chunk)Same asend(java.lang.String)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(String chunk)Same asend(java.lang.String)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(String chunk, String enc)Same asend(java.lang.String)but with anhandlercalled when the operation completesVoidendAndAwait()Blocking variant ofend(java.lang.String).VoidendAndAwait(Buffer chunk)Blocking variant ofend(io.vertx.mutiny.core.buffer.Buffer).VoidendAndAwait(String chunk)Blocking variant ofend(String).VoidendAndAwait(String chunk, String enc)Blocking variant ofend(String,String).voidendAndForget()Variant ofend(java.lang.String)that ignores the result of the operation.voidendAndForget(Buffer chunk)Variant ofend(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.voidendAndForget(String chunk)Variant ofend(String)that ignores the result of the operation.voidendAndForget(String chunk, String enc)Variant ofend(String,String)that ignores the result of the operation.HttpClientRequestendHandler(Consumer<Void> endHandler)Deprecated.booleanequals(Object o)HttpClientRequestexceptionHandler(Consumer<Throwable> handler)HttpClientRequestfetch(long amount)Deprecated.io.vertx.core.http.HttpClientRequestgetDelegate()StringgetHost()StringgetRawMethod()io.vertx.core.http.StreamPrioritygetStreamPriority()HttpClientRequesthandler(Consumer<HttpClientResponse> handler)Deprecated.inthashCode()MultiMapheaders()booleanisChunked()io.vertx.core.http.HttpMethodmethod()static HttpClientRequestnewInstance(io.vertx.core.http.HttpClientRequest arg)Stringpath()HttpClientRequestpause()Deprecated.Pipe<HttpClientResponse>pipe()io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<HttpClientResponse> dst)Pipe thisReadStreamto theWriteStream.VoidpipeToAndAwait(WriteStream<HttpClientResponse> dst)Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream.) voidpipeToAndForget(WriteStream<HttpClientResponse> dst)Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.) HttpClientRequestpushHandler(Consumer<HttpClientRequest> handler)HttpClientRequestputHeader(CharSequence name, CharSequence value)HttpClientRequestputHeader(CharSequence name, Iterable<CharSequence> values)HttpClientRequestputHeader(String name, Iterable<String> values)HttpClientRequestputHeader(String name, String value)Stringquery()booleanreset()booleanreset(long code)HttpClientRequestresume()Deprecated.HttpClientRequestsendHead()HttpClientRequestsendHead(Consumer<io.vertx.core.http.HttpVersion> completionHandler)HttpClientRequestsetChunked(boolean chunked)HttpClientRequestsetFollowRedirects(boolean followRedirects)HttpClientRequestsetHost(String host)HttpClientRequestsetMaxRedirects(int maxRedirects)HttpClientRequestsetRawMethod(String method)HttpClientRequestsetStreamPriority(io.vertx.core.http.StreamPriority streamPriority)HttpClientRequestsetTimeout(long timeoutMs)HttpClientRequestsetWriteQueueMaxSize(int maxSize)intstreamId()Iterable<HttpClientResponse>toBlockingIterable()Stream<HttpClientResponse>toBlockingStream()io.smallrye.mutiny.Multi<HttpClientResponse>toMulti()StringtoString()WriteStreamSubscriber<Buffer>toSubscriber()Stringuri()io.smallrye.mutiny.Uni<Void>write(Buffer data)Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>write(String chunk)Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>write(String chunk, String enc)Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesVoidwriteAndAwait(Buffer data)Blocking variant ofwrite(io.vertx.mutiny.core.buffer.Buffer).VoidwriteAndAwait(String chunk)Blocking variant ofwrite(String).VoidwriteAndAwait(String chunk, String enc)Blocking variant ofwrite(String,String).HttpClientRequestwriteAndForget(Buffer data)Variant ofwrite(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.HttpClientRequestwriteAndForget(String chunk)Variant ofwrite(String)that ignores the result of the operation.HttpClientRequestwriteAndForget(String chunk, String enc)Variant ofwrite(String,String)that ignores the result of the operation.HttpClientRequestwriteCustomFrame(int type, int flags, Buffer payload)HttpClientRequestwriteCustomFrame(HttpFrame frame)booleanwriteQueueFull()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpClientRequest> __TYPE_ARG
-
-
Method Detail
-
getDelegate
public io.vertx.core.http.HttpClientRequest getDelegate()
- Specified by:
getDelegatein interfaceReadStream<HttpClientResponse>- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<Buffer>
-
toSubscriber
public WriteStreamSubscriber<Buffer> toSubscriber()
-
writeQueueFull
public boolean writeQueueFull()
- Specified by:
writeQueueFullin interfaceWriteStream<Buffer>- Returns:
- true if write queue is full
-
pipe
public Pipe<HttpClientResponse> pipe()
- Specified by:
pipein interfaceReadStream<HttpClientResponse>- Returns:
- a pipe
-
pipeTo
public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<HttpClientResponse> dst)
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handlerwill be called with the result.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
pipeToin interfaceReadStream<HttpClientResponse>- Parameters:
dst- the destination write stream- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
public Void pipeToAndAwait(WriteStream<HttpClientResponse> dst)
Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream.) This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
pipeToAndAwaitin interfaceReadStream<HttpClientResponse>- Parameters:
dst- the destination write stream- Returns:
- the Void instance produced by the operation
-
exceptionHandler
public HttpClientRequest exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceReadStream<HttpClientResponse>- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
write
public io.smallrye.mutiny.Uni<Void> write(Buffer data)
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
writein interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(Buffer data)
Blocking variant ofwrite(io.vertx.mutiny.core.buffer.Buffer).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
writeAndAwaitin interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the Void instance produced by the operation
-
setWriteQueueMaxSize
public HttpClientRequest setWriteQueueMaxSize(int maxSize)
- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<Buffer>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
public HttpClientRequest drainHandler(Consumer<Void> handler)
- Specified by:
drainHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
@Deprecated public HttpClientRequest handler(Consumer<HttpClientResponse> handler)
Deprecated.- Specified by:
handlerin interfaceReadStream<HttpClientResponse>- Parameters:
handler-- Returns:
-
pause
@Deprecated public HttpClientRequest pause()
Deprecated.- Specified by:
pausein interfaceReadStream<HttpClientResponse>- Returns:
-
resume
@Deprecated public HttpClientRequest resume()
Deprecated.- Specified by:
resumein interfaceReadStream<HttpClientResponse>- Returns:
-
fetch
@Deprecated public HttpClientRequest fetch(long amount)
Deprecated.- Specified by:
fetchin interfaceReadStream<HttpClientResponse>- Parameters:
amount-- Returns:
-
endHandler
@Deprecated public HttpClientRequest endHandler(Consumer<Void> endHandler)
Deprecated.- Specified by:
endHandlerin interfaceReadStream<HttpClientResponse>- Parameters:
endHandler-- Returns:
-
setFollowRedirects
public HttpClientRequest setFollowRedirects(boolean followRedirects)
- Parameters:
followRedirects-trueto follow HTTP redirects- Returns:
- a reference to this, so the API can be used fluently
-
setMaxRedirects
public HttpClientRequest setMaxRedirects(int maxRedirects)
- Parameters:
maxRedirects- the number of HTTP redirect to follow- Returns:
- a reference to this, so the API can be used fluently
-
setChunked
public HttpClientRequest setChunked(boolean chunked)
- Parameters:
chunked- true if chunked encoding- Returns:
- a reference to this, so the API can be used fluently
-
isChunked
public boolean isChunked()
- Returns:
- Is the request chunked?
-
method
public io.vertx.core.http.HttpMethod method()
- Returns:
-
getRawMethod
public String getRawMethod()
- Returns:
- the raw value of the method this request sends
-
setRawMethod
public HttpClientRequest setRawMethod(String method)
- Parameters:
method- the raw method- Returns:
- a reference to this, so the API can be used fluently
-
absoluteURI
public String absoluteURI()
- Returns:
- the absolute URI corresponding to the the HTTP request
-
uri
public String uri()
- Returns:
- The URI of the request.
-
path
public String path()
- Returns:
- The path part of the uri. For example /somepath/somemorepath/someresource.foo
-
query
public String query()
- Returns:
- the query part of the uri. For example someparam=32&someotherparam=x
-
setHost
public HttpClientRequest setHost(String host)
- Parameters:
host-- Returns:
-
getHost
public String getHost()
- Returns:
- the request host. For HTTP/2 it returns the pseudo header otherwise it returns the header
-
headers
public MultiMap headers()
- Returns:
- The HTTP headers
-
putHeader
public HttpClientRequest putHeader(String name, String value)
- Parameters:
name- The header namevalue- The header value- Returns:
- a reference to this, so the API can be used fluently
-
write
public io.smallrye.mutiny.Uni<Void> write(String chunk)
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(String chunk)
Blocking variant ofwrite(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-- Returns:
- the Void instance produced by the operation
-
write
public io.smallrye.mutiny.Uni<Void> write(String chunk, String enc)
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-enc-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
public Void writeAndAwait(String chunk, String enc)
Blocking variant ofwrite(String,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-enc-- Returns:
- the Void instance produced by the operation
-
continueHandler
public HttpClientRequest continueHandler(Consumer<Void> handler)
- Parameters:
handler-- Returns:
- a reference to this, so the API can be used fluently
-
sendHead
public HttpClientRequest sendHead()
- Returns:
- a reference to this, so the API can be used fluently
-
sendHead
public HttpClientRequest sendHead(Consumer<io.vertx.core.http.HttpVersion> completionHandler)
- Parameters:
completionHandler-- Returns:
-
end
public io.smallrye.mutiny.Uni<Void> end(String chunk)
Same asend(java.lang.String)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void endAndAwait(String chunk)
Blocking variant ofend(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-- Returns:
- the Void instance produced by the operation
-
end
public io.smallrye.mutiny.Uni<Void> end(String chunk, String enc)
Same asend(java.lang.String)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-enc-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void endAndAwait(String chunk, String enc)
Blocking variant ofend(String,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-enc-- Returns:
- the Void instance produced by the operation
-
end
public io.smallrye.mutiny.Uni<Void> end(Buffer chunk)
Same asend(java.lang.String)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
endin interfaceWriteStream<Buffer>- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void endAndAwait(Buffer chunk)
Blocking variant ofend(io.vertx.mutiny.core.buffer.Buffer).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwaitin interfaceWriteStream<Buffer>- Parameters:
chunk-- Returns:
- the Void instance produced by the operation
-
end
public io.smallrye.mutiny.Uni<Void> end()
Same asend(java.lang.String)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
endin interfaceWriteStream<Buffer>- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
public Void endAndAwait()
Blocking variant ofend(java.lang.String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwaitin interfaceWriteStream<Buffer>- Returns:
- the Void instance produced by the operation
-
setTimeout
public HttpClientRequest setTimeout(long timeoutMs)
- Parameters:
timeoutMs- The quantity of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
pushHandler
public HttpClientRequest pushHandler(Consumer<HttpClientRequest> handler)
- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
reset
public boolean reset()
- Returns:
-
reset
public boolean reset(long code)
- Parameters:
code- the error code- Returns:
- true when reset has been performed
-
connection
public HttpConnection connection()
- Returns:
- the
HttpConnectionassociated with this request
-
connectionHandler
@Deprecated public HttpClientRequest connectionHandler(Consumer<HttpConnection> handler)
Deprecated.- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
writeCustomFrame
public HttpClientRequest writeCustomFrame(int type, int flags, Buffer payload)
- Parameters:
type- the 8-bit frame typeflags- the 8-bit frame flagspayload- the frame payload- Returns:
- a reference to this, so the API can be used fluently
-
streamId
public int streamId()
- Returns:
- the id of the stream of this response, when it is not yet determined, i.e the request has not been yet sent or it is not supported HTTP/1.x
-
writeCustomFrame
public HttpClientRequest writeCustomFrame(HttpFrame frame)
- Parameters:
frame- the frame to write- Returns:
-
setStreamPriority
public HttpClientRequest setStreamPriority(io.vertx.core.http.StreamPriority streamPriority)
- Parameters:
streamPriority- the priority of this request's stream- Returns:
-
getStreamPriority
public io.vertx.core.http.StreamPriority getStreamPriority()
- Returns:
- the priority of the associated HTTP/2 stream for HTTP/2 otherwise
null
-
putHeader
public HttpClientRequest putHeader(CharSequence name, CharSequence value)
- Parameters:
name-value-- Returns:
-
putHeader
public HttpClientRequest putHeader(String name, Iterable<String> values)
- Parameters:
name- The header namevalues- The header values- Returns:
-
putHeader
public HttpClientRequest putHeader(CharSequence name, Iterable<CharSequence> values)
- Parameters:
name-values-- Returns:
-
pipeToAndForget
public void pipeToAndForget(WriteStream<HttpClientResponse> dst)
Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreambut you don't need to compose it with other operations.) - Parameters:
dst-
-
writeAndForget
public HttpClientRequest writeAndForget(Buffer data)
Variant ofwrite(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.This method subscribes on the result of
write(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(io.vertx.mutiny.core.buffer.Buffer)but you don't need to compose it with other operations.- Parameters:
data-- Returns:
-
writeAndForget
public HttpClientRequest writeAndForget(String chunk)
Variant ofwrite(String)that ignores the result of the operation.This method subscribes on the result of
write(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String)but you don't need to compose it with other operations.- Parameters:
chunk-- Returns:
-
writeAndForget
public HttpClientRequest writeAndForget(String chunk, String enc)
Variant ofwrite(String,String)that ignores the result of the operation.This method subscribes on the result of
write(String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String,String)but you don't need to compose it with other operations.- Parameters:
chunk-enc-- Returns:
-
endAndForget
public void endAndForget(String chunk)
Variant ofend(String)that ignores the result of the operation.This method subscribes on the result of
end(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(String)but you don't need to compose it with other operations.- Parameters:
chunk-
-
endAndForget
public void endAndForget(String chunk, String enc)
Variant ofend(String,String)that ignores the result of the operation.This method subscribes on the result of
end(String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(String,String)but you don't need to compose it with other operations.- Parameters:
chunk-enc-
-
endAndForget
public void endAndForget(Buffer chunk)
Variant ofend(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.This method subscribes on the result of
end(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(io.vertx.mutiny.core.buffer.Buffer)but you don't need to compose it with other operations.- Parameters:
chunk-
-
endAndForget
public void endAndForget()
Variant ofend(java.lang.String)that ignores the result of the operation.This method subscribes on the result of
end(java.lang.String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(java.lang.String)but you don't need to compose it with other operations.
-
toMulti
public io.smallrye.mutiny.Multi<HttpClientResponse> toMulti()
- Specified by:
toMultiin interfaceReadStream<HttpClientResponse>
-
toBlockingIterable
public Iterable<HttpClientResponse> toBlockingIterable()
-
toBlockingStream
public Stream<HttpClientResponse> toBlockingStream()
-
newInstance
public static HttpClientRequest newInstance(io.vertx.core.http.HttpClientRequest arg)
-
-