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 HTTP CONNECT
method101
for HTTP/1.1 GET
with Upgrade
connection
header The handler
is called after response headers are received.
Use {@link HttpClientResponse#netSocket} to get a for interacting more conveniently with the server.
HTTP/1.1 pipe-lined requests are not supported.f
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 HTTP CONNECT
method101
for HTTP/1.1 GET
with Upgrade
connection
header The handler
is called after response headers are received.
Use {@link HttpClientResponse#netSocket} to get a for interacting more conveniently with the server.
HTTP/1.1 pipe-lined requests are not supported.f
If you send an HTTP request with the header Expect
set to the value 100-continue
and the server responds with an interim HTTP response with a status code of 100
and a Continue handler
has been set using this method, then the handler
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 {@link HttpClientRequest#sendHead} method to force the request header to be written before the request has ended.
If the server responds with an interim HTTP response with a status code of 103
and a Early Hints handler
has been set using this method, then the handler
will be called.
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#end} but with an handler
called when the operation completes
The HTTP method for the request.
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-only HttpClientRequest, the following methods can be called:
In addition the handler should call the {@link HttpClientRequest#response} method to set an handler to process the response.
Put an HTTP header
Like {@link HttpClientRequest#putHeader} but using CharSequence
Put an HTTP header with multiple values
Like {@link HttpClientRequest#putHeader} but using CharSequence
Reset this stream with the error code 0
.
Reset this request:
code
Reset this request:
code
false
is returned as indicator.
Set a callback for the associated HttpClientResponse.
This method does not modify the current request being sent.
Set a callback for the associated HttpClientResponse.
This method does not modify the current request being sent.
Send the request with an empty body.
Send the request with an empty body.
Send the request with a string body
.
Send the request with a string body
.
Send the request with a buffer body
.
Send the request with a buffer body
.
Send the request with a stream body
.
If the CONTENT_LENGTH is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunked CONTENT_ENCODING.
Send the request with a stream body
.
If the CONTENT_LENGTH is set then the request assumes this is the length of the {stream}, otherwise the request will set a chunked CONTENT_ENCODING.
Like {@link HttpClientRequest#sendHead} but with an handler after headers have been sent. The handler will be called with the HttpVersion if it can be determined or null otherwise.
Like {@link HttpClientRequest#sendHead} but with an handler after headers have been sent. The handler will be called with the HttpVersion if it can be determined or null otherwise.
If chunked is true then the request will be set into HTTP chunked mode
Set the request to follow HTTP redirects up to HttpClientOptions.
Set the host value of the HTTP/1.1 host
header or HTTP/2 authority
pseudo header
The initial value is the same than the server socket address host.
Keep in mind that changing this value won't change the actual server socket address for this request.
Set the max number of HTTP redirects this request will follow. The default is 0
which means
no redirects.
Set the HTTP method for this request.
Set the port value of the HTTP/1.1 host
header or HTTP/2 authority
pseudo header
Keep 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.
Sets the priority of the associated stream.
This is not implemented for HTTP/1.x.Set's the amount of time after which if the request does not return any data within the timeout period an TimeoutException will be passed to the exception handler (if provided) and the request will be closed.
Calling this method more than once has the effect of canceling any existing timeout and starting the timeout from scratch.
Set the request uri.
Same as but with an handler
called when the operation completes
Same as but with an handler
called when the operation completes
Same as {@link HttpClientRequest#write} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#write} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#write} but with an handler
called when the operation completes
Same as {@link HttpClientRequest#write} but with an handler
called when the operation completes
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 {@link HttpClientRequest#sendHead} should be used for this purpose.
Like {@link HttpClientRequest#writeCustomFrame} but with an HttpFrame.
This will return true
if there are more bytes in the write queue than the value set using {@link HttpClientRequest#setWriteQueueMaxSize}
Generated using TypeDoc
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 {@link HttpClientRequest#end} 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 {@link HttpClientRequest#end} 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 with Pipe to pipe data with flow control.
An example of using this class is as follows: