Class HttpClientRequest
- java.lang.Object
-
- io.vertx.reactivex.core.http.HttpClientRequest
-
- All Implemented Interfaces:
StreamBase
,WriteStream<Buffer>
public class HttpClientRequest extends Object implements WriteStream<Buffer>
Represents a client-side HTTP request.Instances are created by an
HttpClient
instance, 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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
methods should be called.Nothing is actually sent until the request has been internally assigned an HTTP connection.
The
HttpClient
instance 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, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
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
WriteStream
so it can be used withPipe
to pipe data with flow control.An example of using this class is as follows:
original
non RX-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(HttpClientRequest delegate)
HttpClientRequest(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
absoluteURI()
HttpClientRequest
authority(HostAndPort authority)
Override the request authority, when using HTTP/1.x this overrides the requesthost
header, when using HTTP/2 this sets theauthority
pseudo header.void
connect()
Create an HTTP tunnel to the server.void
connect(Handler<AsyncResult<HttpClientResponse>> handler)
Create an HTTP tunnel to the server.HttpConnection
connection()
HttpClientRequest
continueHandler(Handler<Void> handler)
If you send an HTTP request with the headerExpect
set to the value100-continue
and the server responds with an interim HTTP response with a status code of100
and a Continue handler has been set using this method, then thehandler
will be called.HttpClientRequest
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.HttpClientRequest
earlyHintsHandler(Handler<MultiMap> handler)
If the server responds with an interim HTTP response with a status code of103
and a Early Hints handler has been set using this method, then thehandler
will be called.void
end()
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(Buffer chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(Buffer chunk, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(String chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(String chunk, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(String chunk, String enc)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
end(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesboolean
equals(Object o)
HttpClientRequest
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.HttpClientRequest
getDelegate()
String
getHost()
Deprecated.int
getMaxRedirects()
HttpMethod
getMethod()
The HTTP method for the request.int
getPort()
Deprecated.StreamPriority
getStreamPriority()
String
getURI()
int
hashCode()
MultiMap
headers()
HttpClientRequest
idleTimeout(long timeout)
Sets the amount of time after which, if the request does not return any data within the timeout period, the request/response is closed and the related futures are failed with aTimeoutException
, e.g.boolean
isChunked()
boolean
isFollowRedirects()
static HttpClientRequest
newInstance(HttpClientRequest arg)
int
numberOfRedirections()
String
path()
HttpClientRequest
pushHandler(Handler<HttpClientRequest> handler)
Set a push handler for this request.HttpClientRequest
putHeader(CharSequence name, CharSequence value)
LikeputHeader(java.lang.String, java.lang.String)
but using CharSequenceHttpClientRequest
putHeader(CharSequence name, Iterable<CharSequence> values)
LikeputHeader(java.lang.String, java.lang.String)
but using CharSequenceHttpClientRequest
putHeader(String name, Iterable<String> values)
Put an HTTP header with multiple valuesHttpClientRequest
putHeader(String name, String value)
Put an HTTP headerString
query()
HttpClientRequest
redirectHandler(io.reactivex.functions.Function<HttpClientResponse,io.reactivex.Single<HttpClientRequest>> handler)
HttpClientRequest
redirectHandler(Function<HttpClientResponse,Future<HttpClientRequest>> handler)
boolean
reset()
Reset this stream with the error code0
.boolean
reset(long code)
Reset this request:boolean
reset(long code, Throwable cause)
Reset this request:HttpClientRequest
response()
Set a callback for the associatedHttpClientResponse
.HttpClientRequest
response(Handler<AsyncResult<HttpClientResponse>> handler)
Set a callback for the associatedHttpClientResponse
.io.reactivex.Single<HttpClientResponse>
rxConnect()
Create an HTTP tunnel to the server.io.reactivex.Completable
rxEnd()
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Completable
rxEnd(Buffer chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Completable
rxEnd(String chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Completable
rxEnd(String chunk, String enc)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Single<HttpClientResponse>
rxResponse()
Set a callback for the associatedHttpClientResponse
.io.reactivex.Single<HttpClientResponse>
rxSend()
Send the request with an empty body.io.reactivex.Single<HttpClientResponse>
rxSend(io.reactivex.Flowable<Buffer> body)
Send the request with a streambody
.io.reactivex.Single<HttpClientResponse>
rxSend(Buffer body)
Send the request with a bufferbody
.io.reactivex.Single<HttpClientResponse>
rxSend(ReadStream<Buffer> body)
Send the request with a streambody
.io.reactivex.Single<HttpClientResponse>
rxSend(String body)
Send the request with a stringbody
.io.reactivex.Completable
rxSendHead()
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent.io.reactivex.Completable
rxWrite(Buffer data)
Same as but with anhandler
called when the operation completesio.reactivex.Completable
rxWrite(String chunk)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesio.reactivex.Completable
rxWrite(String chunk, String enc)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
send()
Send the request with an empty body.void
send(io.reactivex.Flowable<Buffer> body)
Send the request with a streambody
.void
send(io.reactivex.Flowable<Buffer> body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a streambody
.void
send(Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with an empty body.void
send(Buffer body)
Send the request with a bufferbody
.void
send(Buffer body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a bufferbody
.void
send(ReadStream<Buffer> body)
Send the request with a streambody
.void
send(ReadStream<Buffer> body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a streambody
.void
send(String body)
Send the request with a stringbody
.void
send(String body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a stringbody
.HttpClientRequest
sendHead()
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent.HttpClientRequest
sendHead(Handler<AsyncResult<Void>> completionHandler)
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent.HttpClientRequest
setChunked(boolean chunked)
If chunked is true then the request will be set into HTTP chunked modeHttpClientRequest
setFollowRedirects(boolean followRedirects)
Set the request to follow HTTP redirects up toHttpClientOptions
.HttpClientRequest
setHost(String host)
Deprecated.HttpClientRequest
setMaxRedirects(int maxRedirects)
Set the max number of HTTP redirects this request will follow.HttpClientRequest
setMethod(HttpMethod method)
Set the HTTP method for this request.HttpClientRequest
setPort(int port)
Deprecated.HttpClientRequest
setStreamPriority(StreamPriority streamPriority)
Sets the priority of the associated stream.HttpClientRequest
setTimeout(long timeout)
Deprecated.HttpClientRequest
setURI(String uri)
Set the request uri.HttpClientRequest
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue tomaxSize
.int
streamId()
WriteStreamObserver<Buffer>
toObserver()
String
toString()
WriteStreamSubscriber<Buffer>
toSubscriber()
String
traceOperation()
HttpClientRequest
traceOperation(String op)
Set the trace operation of this request.HttpVersion
version()
void
write(Buffer data)
Same as but with anhandler
called when the operation completesvoid
write(Buffer data, Handler<AsyncResult<Void>> handler)
Same as but with anhandler
called when the operation completesvoid
write(String chunk)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
write(String chunk, Handler<AsyncResult<Void>> handler)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
write(String chunk, String enc)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesvoid
write(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completesHttpClientRequest
writeCustomFrame(int type, int flags, Buffer payload)
Write an HTTP/2 frame to the request, allowing to extend the HTTP/2 protocol.HttpClientRequest
writeCustomFrame(HttpFrame frame)
LikewriteCustomFrame(int, int, io.vertx.reactivex.core.buffer.Buffer)
but with anHttpFrame
.boolean
writeQueueFull()
This will returntrue
if there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpClientRequest> __TYPE_ARG
-
-
Constructor Detail
-
HttpClientRequest
public HttpClientRequest(HttpClientRequest delegate)
-
HttpClientRequest
public HttpClientRequest(Object delegate)
-
-
Method Detail
-
getDelegate
public HttpClientRequest getDelegate()
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in interfaceWriteStream<Buffer>
-
toObserver
public WriteStreamObserver<Buffer> toObserver()
-
toSubscriber
public WriteStreamSubscriber<Buffer> toSubscriber()
-
write
public void write(Buffer data, Handler<AsyncResult<Void>> handler)
Same as but with anhandler
called when the operation completes- Specified by:
write
in interfaceWriteStream<Buffer>
- Parameters:
data
-handler
-
-
write
public void write(Buffer data)
Same as but with anhandler
called when the operation completes- Specified by:
write
in interfaceWriteStream<Buffer>
- Parameters:
data
-
-
rxWrite
public io.reactivex.Completable rxWrite(Buffer data)
Same as but with anhandler
called when the operation completes- Specified by:
rxWrite
in interfaceWriteStream<Buffer>
- Parameters:
data
-- Returns:
-
writeQueueFull
public boolean writeQueueFull()
This will returntrue
if there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
- Specified by:
writeQueueFull
in interfaceWriteStream<Buffer>
- Returns:
true
if write queue is full
-
exceptionHandler
public HttpClientRequest exceptionHandler(Handler<Throwable> handler)
Description copied from interface:WriteStream
Set an exception handler on the write stream.- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
public HttpClientRequest setWriteQueueMaxSize(int maxSize)
Description copied from interface:WriteStream
Set the maximum size of the write queue tomaxSize
. You will still be able to write to the stream even if there is more thanmaxSize
items in the write queue. This is used as an indicator by classes such asPipe
to provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket
, etc...- Specified by:
setWriteQueueMaxSize
in 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(Handler<Void> handler)
Description copied from interface:WriteStream
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. SeePipe
for an example of this being used.The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to
maxSize / 2
.- Specified by:
drainHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the handler- Returns:
- a reference to this, so the API can be used fluently
-
authority
public HttpClientRequest authority(HostAndPort authority)
Override the request authority, when using HTTP/1.x this overrides the requesthost
header, when using HTTP/2 this sets theauthority
pseudo header. When the port is a negative value, the default scheme port will be used.The default request authority is the server host and port when connecting to the server.
- Parameters:
authority
- override the request authority- Returns:
- a reference to this, so the API can be used fluently
-
setHost
@Deprecated public HttpClientRequest setHost(String host)
Deprecated.Set the host value of the HTTP/1.1host
header or HTTP/2authority
pseudo headerThe initial value is the same as the server socket address host.
Keep in mind that changing this value won't change the actual server socket address for this request.
- Parameters:
host
- the host part of the HTTP/1.1host
header or HTTP/2authority
pseudo header- Returns:
- a reference to this, so the API can be used fluently
-
getHost
@Deprecated public String getHost()
Deprecated.- Returns:
- the host value of the HTTP/1.1
host
header or HTTP/2authority
pseudo header
-
setPort
@Deprecated public HttpClientRequest setPort(int port)
Deprecated.Set the port value of the HTTP/1.1host
header or HTTP/2authority
pseudo headerKeep in mind that this won't change the actual server socket address for this request.
The initial value is the same than the server socket address port.
- Parameters:
port
- the port part of the HTTP/1.1host
header or HTTP/2authority
pseudo header- Returns:
- a reference to this, so the API can be used fluently
-
getPort
@Deprecated public int getPort()
Deprecated.- Returns:
- the port value of the HTTP/1.1
host
header or HTTP/2authority
pseudo header
-
setFollowRedirects
public HttpClientRequest setFollowRedirects(boolean followRedirects)
Set the request to follow HTTP redirects up toHttpClientOptions
.- Parameters:
followRedirects
-true
to follow HTTP redirects- Returns:
- a reference to this, so the API can be used fluently
-
isFollowRedirects
public boolean isFollowRedirects()
- Returns:
- whether HTTP redirections should be followed
-
setMaxRedirects
public HttpClientRequest setMaxRedirects(int maxRedirects)
Set the max number of HTTP redirects this request will follow. The default is0
which means no redirects.- Parameters:
maxRedirects
- the number of HTTP redirect to follow- Returns:
- a reference to this, so the API can be used fluently
-
getMaxRedirects
public int getMaxRedirects()
- Returns:
- the maximum number of HTTP redirections to follow
-
numberOfRedirections
public int numberOfRedirections()
- Returns:
- the number of followed redirections for the current HTTP request
-
setChunked
public HttpClientRequest setChunked(boolean chunked)
If chunked is true then the request will be set into HTTP chunked mode- 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?
-
getMethod
public HttpMethod getMethod()
The HTTP method for the request.- Returns:
-
setMethod
public HttpClientRequest setMethod(HttpMethod method)
Set the HTTP method for this request.- Parameters:
method
- the HTTP method- Returns:
- a reference to this, so the API can be used fluently
-
absoluteURI
public String absoluteURI()
- Returns:
- the absolute URI corresponding to the HTTP request
-
getURI
public String getURI()
- Returns:
- The URI of the request.
-
setURI
public HttpClientRequest setURI(String uri)
Set the request uri.- Parameters:
uri
- the request uri- Returns:
- a reference to this, so the API can be used fluently
-
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
-
headers
public MultiMap headers()
- Returns:
- The HTTP headers
-
putHeader
public HttpClientRequest putHeader(String name, String value)
Put an HTTP header- Parameters:
name
- The header namevalue
- The header value- Returns:
- a reference to this, so the API can be used fluently
-
traceOperation
public HttpClientRequest traceOperation(String op)
Set the trace operation of this request.- Parameters:
op
- the operation- Returns:
-
traceOperation
public String traceOperation()
- Returns:
- the trace operation of this request
-
version
public HttpVersion version()
- Returns:
- the HTTP version for this request
-
write
public void write(String chunk, Handler<AsyncResult<Void>> handler)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-handler
-
-
write
public void write(String chunk)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-
-
rxWrite
public io.reactivex.Completable rxWrite(String chunk)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-- Returns:
-
write
public void write(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-handler
-
-
write
public void write(String chunk, String enc)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-
-
rxWrite
public io.reactivex.Completable rxWrite(String chunk, String enc)
Same aswrite(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-- Returns:
-
continueHandler
public HttpClientRequest continueHandler(Handler<Void> handler)
If you send an HTTP request with the headerExpect
set to the value100-continue
and the server responds with an interim HTTP response with a status code of100
and a Continue handler has been set using this method, then thehandler
will be called.You can then continue to write data to the request body and later end it. This is normally used in conjunction with the
sendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
method to force the request header to be written before the request has ended.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
earlyHintsHandler
public HttpClientRequest earlyHintsHandler(Handler<MultiMap> handler)
If the server responds with an interim HTTP response with a status code of103
and a Early Hints handler has been set using this method, then thehandler
will be called.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
redirectHandler
public HttpClientRequest redirectHandler(Function<HttpClientResponse,Future<HttpClientRequest>> handler)
-
redirectHandler
public HttpClientRequest redirectHandler(io.reactivex.functions.Function<HttpClientResponse,io.reactivex.Single<HttpClientRequest>> handler)
-
sendHead
public HttpClientRequest sendHead(Handler<AsyncResult<Void>> completionHandler)
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent. The handler will be called with theHttpVersion
if it can be determined or null otherwise.- Parameters:
completionHandler
-- Returns:
-
sendHead
public HttpClientRequest sendHead()
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent. The handler will be called with theHttpVersion
if it can be determined or null otherwise.- Returns:
-
rxSendHead
public io.reactivex.Completable rxSendHead()
LikesendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler after headers have been sent. The handler will be called with theHttpVersion
if it can be determined or null otherwise.- Returns:
-
connect
public void connect(Handler<AsyncResult<HttpClientResponse>> handler)
Create an HTTP tunnel to the server.Send HTTP request headers to the server, then configures the transport to exchange raw buffers when the server replies with an appropriate response:
200
for HTTPCONNECT
method101
for HTTP/1.1GET
withUpgrade
connection
header
The
handler
is called after response headers are received.Use
HttpClientResponse.netSocket()
to get a for interacting more conveniently with the server.HTTP/1.1 pipe-lined requests are not supported.f
- Parameters:
handler
- the response completion handler
-
connect
public void connect()
Create an HTTP tunnel to the server.Send HTTP request headers to the server, then configures the transport to exchange raw buffers when the server replies with an appropriate response:
200
for HTTPCONNECT
method101
for HTTP/1.1GET
withUpgrade
connection
header
The
handler
is called after response headers are received.Use
HttpClientResponse.netSocket()
to get a for interacting more conveniently with the server.HTTP/1.1 pipe-lined requests are not supported.f
-
rxConnect
public io.reactivex.Single<HttpClientResponse> rxConnect()
Create an HTTP tunnel to the server.Send HTTP request headers to the server, then configures the transport to exchange raw buffers when the server replies with an appropriate response:
200
for HTTPCONNECT
method101
for HTTP/1.1GET
withUpgrade
connection
header
The
handler
is called after response headers are received.Use
HttpClientResponse.netSocket()
to get a for interacting more conveniently with the server.HTTP/1.1 pipe-lined requests are not supported.f
- Returns:
-
response
public HttpClientRequest response(Handler<AsyncResult<HttpClientResponse>> handler)
Set a callback for the associatedHttpClientResponse
.This method does not modify the current request being sent.
- Parameters:
handler
- the completion handler- Returns:
- a reference to this, so the API can be used fluently
-
response
public HttpClientRequest response()
Set a callback for the associatedHttpClientResponse
.This method does not modify the current request being sent.
- Returns:
- a reference to this, so the API can be used fluently
-
rxResponse
public io.reactivex.Single<HttpClientResponse> rxResponse()
Set a callback for the associatedHttpClientResponse
.This method does not modify the current request being sent.
- Returns:
- a reference to this, so the API can be used fluently
-
send
public void send(Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with an empty body.- Parameters:
handler
- the completion handler for theHttpClientResponse
-
send
public void send()
Send the request with an empty body.
-
rxSend
public io.reactivex.Single<HttpClientResponse> rxSend()
Send the request with an empty body.- Returns:
-
send
public void send(String body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a stringbody
.- Parameters:
body
-handler
- the completion handler for theHttpClientResponse
-
send
public void send(String body)
Send the request with a stringbody
.- Parameters:
body
-
-
rxSend
public io.reactivex.Single<HttpClientResponse> rxSend(String body)
Send the request with a stringbody
.- Parameters:
body
-- Returns:
-
send
public void send(Buffer body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a bufferbody
.- Parameters:
body
-handler
- the completion handler for theHttpClientResponse
-
send
public void send(Buffer body)
Send the request with a bufferbody
.- Parameters:
body
-
-
rxSend
public io.reactivex.Single<HttpClientResponse> rxSend(Buffer body)
Send the request with a bufferbody
.- Parameters:
body
-- Returns:
-
send
public void send(ReadStream<Buffer> body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-handler
- the completion handler for theHttpClientResponse
-
send
public void send(ReadStream<Buffer> body)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-
-
rxSend
public io.reactivex.Single<HttpClientResponse> rxSend(ReadStream<Buffer> body)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-- Returns:
-
send
public void send(io.reactivex.Flowable<Buffer> body, Handler<AsyncResult<HttpClientResponse>> handler)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-handler
- the completion handler for theHttpClientResponse
-
send
public void send(io.reactivex.Flowable<Buffer> body)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-
-
rxSend
public io.reactivex.Single<HttpClientResponse> rxSend(io.reactivex.Flowable<Buffer> body)
Send the request with a streambody
.If the
HttpHeaders
is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders
.- Parameters:
body
-- Returns:
-
end
public void end(String chunk, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-handler
-
-
end
public void end(String chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-
-
rxEnd
public io.reactivex.Completable rxEnd(String chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-- Returns:
-
end
public void end(String chunk, String enc, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-handler
-
-
end
public void end(String chunk, String enc)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-
-
rxEnd
public io.reactivex.Completable rxEnd(String chunk, String enc)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Parameters:
chunk
-enc
-- Returns:
-
end
public void end(Buffer chunk, Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<Buffer>
- Parameters:
chunk
-handler
-
-
end
public void end(Buffer chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<Buffer>
- Parameters:
chunk
-
-
rxEnd
public io.reactivex.Completable rxEnd(Buffer chunk)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
rxEnd
in interfaceWriteStream<Buffer>
- Parameters:
chunk
-- Returns:
-
end
public void end(Handler<AsyncResult<Void>> handler)
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<Buffer>
- Parameters:
handler
-
-
end
public void end()
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
end
in interfaceWriteStream<Buffer>
-
rxEnd
public io.reactivex.Completable rxEnd()
Same asend(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with anhandler
called when the operation completes- Specified by:
rxEnd
in interfaceWriteStream<Buffer>
- Returns:
-
setTimeout
@Deprecated public HttpClientRequest setTimeout(long timeout)
Deprecated.LikeidleTimeout(long)
but with a confusing name (hence the deprecation).- Parameters:
timeout
-- Returns:
-
idleTimeout
public HttpClientRequest idleTimeout(long timeout)
Sets the amount of time after which, if the request does not return any data within the timeout period, the request/response is closed and the related futures are failed with aTimeoutException
, e.g.Future
orFuture
response body.- Parameters:
timeout
- the amount of time in milliseconds.- Returns:
- a reference to this, so the API can be used fluently
-
pushHandler
public HttpClientRequest pushHandler(Handler<HttpClientRequest> handler)
Set a push handler for this request. The handler is called when the client receives a push promise from the server. The handler can be called multiple times, for each push promise. The handler is called with a read-onlyHttpClientRequest
, the following methods can be called: In addition the handler should call theresponse(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpClientResponse>>)
method to set an handler to process the response.- Parameters:
handler
- the handler- Returns:
- a reference to this, so the API can be used fluently
-
reset
public boolean reset()
Reset this stream with the error code0
.- Returns:
-
reset
public boolean reset(long code)
Reset this request:- for HTTP/2, this performs send an HTTP/2 reset frame with the specified error
code
- for HTTP/1.x, this closes the connection when the current request is inflight
- Parameters:
code
- the error code- Returns:
true
when reset has been performed
- for HTTP/2, this performs send an HTTP/2 reset frame with the specified error
-
reset
public boolean reset(long code, Throwable cause)
Reset this request:- for HTTP/2, send an HTTP/2 reset frame with the specified error
code
- for HTTP/1.x, close the connection when the current request is inflight
false
is returned as indicator.- Parameters:
code
- the error codecause
- an optional cause that can be attached to the error code- Returns:
- true when reset has been performed
- for HTTP/2, send an HTTP/2 reset frame with the specified error
-
connection
public HttpConnection connection()
- Returns:
- the
HttpConnection
associated with this request
-
writeCustomFrame
public HttpClientRequest writeCustomFrame(int type, int flags, Buffer payload)
Write an HTTP/2 frame to the request, allowing to extend the HTTP/2 protocol.The frame is sent immediatly and is not subject to flow control.
This method must be called after the request headers have been sent and only for the protocol HTTP/2. The
sendHead(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
should be used for this purpose.- 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)
LikewriteCustomFrame(int, int, io.vertx.reactivex.core.buffer.Buffer)
but with anHttpFrame
.- Parameters:
frame
- the frame to write- Returns:
-
setStreamPriority
public HttpClientRequest setStreamPriority(StreamPriority streamPriority)
Sets the priority of the associated stream. This is not implemented for HTTP/1.x.- Parameters:
streamPriority
- the priority of this request's stream- Returns:
-
getStreamPriority
public StreamPriority getStreamPriority()
- Returns:
- the priority of the associated HTTP/2 stream for HTTP/2 otherwise
null
-
putHeader
public HttpClientRequest putHeader(CharSequence name, CharSequence value)
LikeputHeader(java.lang.String, java.lang.String)
but using CharSequence- Parameters:
name
-value
-- Returns:
-
putHeader
public HttpClientRequest putHeader(String name, Iterable<String> values)
Put an HTTP header with multiple values- Parameters:
name
- The header namevalues
- The header values- Returns:
-
putHeader
public HttpClientRequest putHeader(CharSequence name, Iterable<CharSequence> values)
LikeputHeader(java.lang.String, java.lang.String)
but using CharSequence- Parameters:
name
-values
-- Returns:
-
newInstance
public static HttpClientRequest newInstance(HttpClientRequest arg)
-
-