public class HttpClientRequestImpl extends HttpClientRequestBase implements HttpClientRequest
this for synchronization purpose. The HttpClientRequestBase.client orHttpClientRequestBase.stream instead are
called must not be called under this lock to avoid deadlocks.| Modifier and Type | Method and Description |
|---|---|
Future<HttpClientResponse> |
connect()
Like
HttpClientRequest.connect(Handler) but returns a Future of the asynchronous result |
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 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. |
HttpClientRequest |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
Future<Void> |
end()
Ends the request.
|
Future<Void> |
end(Buffer chunk)
Same as
HttpClientRequest.end() but writes some data to the request body before ending. |
void |
end(Buffer chunk,
Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.end(String) but with an handler called when the operation completes |
void |
end(Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.end() but with an handler called when the operation completes |
Future<Void> |
end(String chunk)
Same as
HttpClientRequest.end(Buffer) but writes a String in UTF-8 encoding |
void |
end(String chunk,
Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.end(String) but with an handler called when the operation completes |
Future<Void> |
end(String chunk,
String enc)
Same as
HttpClientRequest.end(Buffer) but writes a String with the specified encoding |
void |
end(String chunk,
String enc,
Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.end(String,String) but with an handler called when the operation completes |
HttpClientRequest |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
StreamPriority |
getStreamPriority() |
MultiMap |
headers() |
boolean |
isChunked() |
HttpClientRequest |
putHeader(CharSequence name,
CharSequence value)
Like
HttpClientRequest.putHeader(String, String) but using CharSequence |
HttpClientRequest |
putHeader(CharSequence name,
Iterable<CharSequence> values)
Like
HttpClientRequest.putHeader(String, Iterable) but using CharSequence |
HttpClientRequest |
putHeader(String name,
Iterable<String> values)
Put an HTTP header with multiple values
|
HttpClientRequest |
putHeader(String name,
String value)
Put an HTTP header
|
Future<Void> |
sendHead()
Forces the head of the request to be written before
HttpClientRequest.end() is called on the request or any data is
written to it. |
HttpClientRequest |
sendHead(Handler<AsyncResult<Void>> headersHandler)
Like
HttpClientRequest.sendHead() but with an handler after headers have been sent. |
HttpClientRequestImpl |
setChunked(boolean chunked)
If chunked is true then the request will be set into HTTP chunked mode
|
HttpClientRequest |
setFollowRedirects(boolean followRedirects)
Set the request to follow HTTP redirects up to
HttpClientOptions.getMaxRedirects(). |
HttpClientRequest |
setMaxRedirects(int maxRedirects)
Set the max number of HTTP redirects this request will follow.
|
HttpClientRequest |
setStreamPriority(StreamPriority priority)
Sets the priority of the associated stream.
|
HttpClientRequest |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
HttpVersion |
version() |
Future<Void> |
write(Buffer chunk)
Write some data to the stream.
|
void |
write(Buffer chunk,
Handler<AsyncResult<Void>> handler)
Same as
#write(T) but with an handler called when the operation completes |
Future<Void> |
write(String chunk)
Write a
String to the request body, encoded as UTF-8. |
void |
write(String chunk,
Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.write(String) but with an handler called when the operation completes |
Future<Void> |
write(String chunk,
String enc)
Write a
String to the request body, encoded using the encoding enc. |
void |
write(String chunk,
String enc,
Handler<AsyncResult<Void>> handler)
Same as
HttpClientRequest.write(String,String) but with an handler called when the operation completes |
HttpClientRequest |
writeCustomFrame(int type,
int flags,
Buffer payload)
Write an HTTP/2 frame to the request, allowing to extend the HTTP/2 protocol.
|
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
absoluteURI, authority, getHost, getMethod, getPort, getURI, path, pushHandler, query, reset, reset, response, response, setHost, setMethod, setPort, setTimeout, setURI, streamIdclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabsoluteURI, getHost, getMethod, getPort, getURI, path, pushHandler, query, reset, reset, reset, response, response, send, send, send, send, send, send, send, send, setHost, setMethod, setPort, setTimeout, setURI, streamId, writeCustomFramepublic HttpClientRequest setFollowRedirects(boolean followRedirects)
HttpClientRequestHttpClientOptions.getMaxRedirects().setFollowRedirects in interface HttpClientRequestfollowRedirects - true to follow HTTP redirectspublic HttpClientRequest setMaxRedirects(int maxRedirects)
HttpClientRequest0 which means
no redirects.setMaxRedirects in interface HttpClientRequestmaxRedirects - the number of HTTP redirect to followpublic HttpClientRequestImpl setChunked(boolean chunked)
HttpClientRequestsetChunked in interface HttpClientRequestchunked - true if chunked encodingpublic boolean isChunked()
isChunked in interface HttpClientRequestpublic MultiMap headers()
headers in interface HttpClientRequestpublic HttpClientRequest putHeader(String name, String value)
HttpClientRequestputHeader in interface HttpClientRequestname - The header namevalue - The header valuepublic HttpClientRequest putHeader(String name, Iterable<String> values)
HttpClientRequestputHeader in interface HttpClientRequestname - The header namevalues - The header valuespublic HttpClientRequest setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize items in the write queue. This is used as an indicator by classes such as
Pipe to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket, etc...setWriteQueueMaxSize in interface HttpClientRequestsetWriteQueueMaxSize in interface WriteStream<Buffer>maxSize - the max size of the write streampublic boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<Buffer>true if write queue is fullpublic HttpVersion version()
version in interface HttpClientRequestpublic HttpClientRequest exceptionHandler(Handler<Throwable> handler)
WriteStreamexceptionHandler in interface HttpClientRequestexceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<Buffer>handler - the exception handlerpublic HttpClientRequest drainHandler(Handler<Void> handler)
WriteStreamPipe 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.
drainHandler in interface HttpClientRequestdrainHandler in interface WriteStream<Buffer>handler - the handlerpublic HttpClientRequest continueHandler(Handler<Void> handler)
HttpClientRequestExpect 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 HttpClientRequest.sendHead() method to force the request header to be written before the request has ended.
continueHandler in interface HttpClientRequestpublic Future<Void> sendHead()
HttpClientRequestHttpClientRequest.end() is called on the request or any data is
written to it.
This is normally used to implement HTTP 100-continue handling, see HttpClientRequest.continueHandler(io.vertx.core.Handler) for
more information.
sendHead in interface HttpClientRequestpublic HttpClientRequest sendHead(Handler<AsyncResult<Void>> headersHandler)
HttpClientRequestHttpClientRequest.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.sendHead in interface HttpClientRequestpublic Future<HttpClientResponse> connect()
HttpClientRequestHttpClientRequest.connect(Handler) but returns a Future of the asynchronous resultconnect in interface HttpClientRequestpublic void connect(Handler<AsyncResult<HttpClientResponse>> handler)
HttpClientRequestSend an HTTP request 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 HttpClientResponse.netSocket() to get a NetSocket for the interacting
more conveniently with the server.
HTTP/1.1 pipe-lined requests are not supported.
connect in interface HttpClientRequesthandler - the response completion handlerpublic HttpClientRequest putHeader(CharSequence name, CharSequence value)
HttpClientRequestHttpClientRequest.putHeader(String, String) but using CharSequenceputHeader in interface HttpClientRequestpublic HttpClientRequest putHeader(CharSequence name, Iterable<CharSequence> values)
HttpClientRequestHttpClientRequest.putHeader(String, Iterable) but using CharSequenceputHeader in interface HttpClientRequestpublic HttpConnection connection()
connection in interface HttpClientRequestHttpConnection associated with this requestpublic HttpClientRequest writeCustomFrame(int type, int flags, Buffer payload)
HttpClientRequestThe 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 HttpClientRequest.sendHead(Handler) should be used for this purpose.
writeCustomFrame in interface HttpClientRequesttype - the 8-bit frame typeflags - the 8-bit frame flagspayload - the frame payloadpublic Future<Void> end(String chunk)
HttpClientRequestHttpClientRequest.end(Buffer) but writes a String in UTF-8 encodingend in interface HttpClientRequestchunk - the data chunkpublic void end(String chunk, Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.end(String) but with an handler called when the operation completesend in interface HttpClientRequestpublic Future<Void> end(String chunk, String enc)
HttpClientRequestHttpClientRequest.end(Buffer) but writes a String with the specified encodingend in interface HttpClientRequestchunk - the data chunkenc - the encodingpublic void end(String chunk, String enc, Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.end(String,String) but with an handler called when the operation completesend in interface HttpClientRequestpublic Future<Void> end(Buffer chunk)
HttpClientRequestHttpClientRequest.end() but writes some data to the request body before ending. If the request is not chunked and
no other data has been written then the Content-Length header will be automatically setend in interface HttpClientRequestend in interface WriteStream<Buffer>chunk - the data to writepublic void end(Buffer chunk, Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.end(String) but with an handler called when the operation completesend in interface HttpClientRequestend in interface WriteStream<Buffer>public Future<Void> end()
HttpClientRequestHttpClientRequest.sendHead() has not been called then
the actual request won't get written until this method gets called.
Once the request has ended, it cannot be used any more,
end in interface HttpClientRequestend in interface WriteStream<Buffer>public void end(Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.end() but with an handler called when the operation completesend in interface HttpClientRequestend in interface WriteStream<Buffer>public Future<Void> write(Buffer chunk)
WriteStream The data is usually put on an internal write queue, and the write actually happens
asynchronously. To avoid running out of memory by putting too much on the write queue,
check the WriteStream.writeQueueFull() method before writing. This is done automatically if
using a Pipe.
When the data is moved from the queue to the actual medium, the returned
Future will be completed with the write result, e.g the future is succeeded
when a server HTTP response buffer is written to the socket and failed if the remote
client has closed the socket while the data was still pending for write.
write in interface WriteStream<Buffer>chunk - the data to writepublic void write(Buffer chunk, Handler<AsyncResult<Void>> handler)
WriteStream#write(T) but with an handler called when the operation completeswrite in interface WriteStream<Buffer>public Future<Void> write(String chunk)
HttpClientRequestString to the request body, encoded as UTF-8.write in interface HttpClientRequestchunk - the data chunkpublic void write(String chunk, Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.write(String) but with an handler called when the operation completeswrite in interface HttpClientRequestpublic Future<Void> write(String chunk, String enc)
HttpClientRequestString to the request body, encoded using the encoding enc.write in interface HttpClientRequestchunk - the data chunkenc - the encodingpublic void write(String chunk, String enc, Handler<AsyncResult<Void>> handler)
HttpClientRequestHttpClientRequest.write(String,String) but with an handler called when the operation completeswrite in interface HttpClientRequestpublic HttpClientRequest setStreamPriority(StreamPriority priority)
HttpClientRequestsetStreamPriority in interface HttpClientRequestpriority - the priority of this request's streampublic StreamPriority getStreamPriority()
getStreamPriority in interface HttpClientRequestnullCopyright © 2021. All rights reserved.