new HttpClientRequest()
Represents a client-side HTTP request.
- Source:
Methods
absoluteURI() → {string}
- Source:
Returns:
the absolute URI corresponding to the the HTTP request
-
Type
-
string
compose(mapper) → {Future}
Compose this future with a
mapper function.
When this future (the one on which compose is called) succeeds, the mapper will be called with
the completed value and this mapper returns another future object. This returned future completion will complete
the future returned by this method call.
If the mapper throws an exception, the returned future will be failed with this exception.
When this future fails, the failure will be propagated to the returned future and the mapper
will not be called.
Parameters:
| Name |
Type |
Description |
mapper |
function
|
the mapper function |
- Source:
Returns:
the composed future
-
Type
-
Future
connection() → {HttpConnection}
- Source:
Returns:
the HttpConnection associated with this request
-
Type
-
HttpConnection
connectionHandler(handler) → {HttpClientRequest}
Set a connection handler called when an HTTP connection has been established.
Parameters:
| Name |
Type |
Description |
handler |
function
|
the handler |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
continueHandler(handler) → {HttpClientRequest}
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 HttpClientRequest#sendHead method to force the request header to be written before the request has ended.
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
drainHandler(handler) → {HttpClientRequest}
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
end(handler)
Same as HttpClientRequest#end but with an handler called when the operation completes
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
exceptionHandler(handler) → {HttpClientRequest}
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
getHandler() → {function}
- Source:
Returns:
the handler for the result
-
Type
-
function
getHost() → {string}
- Source:
Returns:
the request host. For HTTP/2 it returns the pseudo header otherwise it returns the header
-
Type
-
string
getRawMethod() → {string}
- Source:
Returns:
the raw value of the method this request sends
-
Type
-
string
getStreamPriority() → {Object}
- Source:
Returns:
the priority of the associated HTTP/2 stream for HTTP/2 otherwise null
-
Type
-
Object
- Source:
Returns:
The HTTP headers
-
Type
-
MultiMap
isChunked() → {boolean}
- Source:
Returns:
Is the request chunked?
-
Type
-
boolean
map(mapper) → {Future}
Apply a
mapper function on this future.
When this future succeeds, the mapper will be called with the completed value and this mapper
returns a value. This value will complete the future returned by this method call.
If the mapper throws an exception, the returned future will be failed with this exception.
When this future fails, the failure will be propagated to the returned future and the mapper
will not be called.
Parameters:
| Name |
Type |
Description |
mapper |
function
|
the mapper function |
- Source:
Returns:
the mapped future
-
Type
-
Future
method() → {Object}
The HTTP method for the request.
- Source:
Returns:
-
Type
-
Object
otherwise(value) → {Future}
Map the failure of a future to a specific
value.
When this future fails, this value will complete the future returned by this method call.
When this future succeeds, the result will be propagated to the returned future.
Parameters:
| Name |
Type |
Description |
value |
HttpClientResponse
|
the value that eventually completes the mapped future |
- Source:
Returns:
the mapped future
-
Type
-
Future
otherwiseEmpty() → {Future}
Map the failure of a future to
null.
This is a convenience for future.otherwise((T) null).
When this future fails, the null value will complete the future returned by this method call.
When this future succeeds, the result will be propagated to the returned future.
- Source:
Returns:
the mapped future
-
Type
-
Future
path() → {string}
- Source:
Returns:
The path part of the uri. For example /somepath/somemorepath/someresource.foo
-
Type
-
string
pushHandler(handler) → {HttpClientRequest}
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:
- HttpClientRequest#method
- HttpClientRequest#uri
- HttpClientRequest#headers
- HttpClientRequest#getHost
In addition the handler should call the HttpClientRequest#setHandler method to set an handler to
process the response.
Parameters:
| Name |
Type |
Description |
handler |
function
|
the handler |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
Put an HTTP header
Parameters:
| Name |
Type |
Description |
name |
string
|
The header name |
value |
string
|
The header value |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
query() → {string}
- Source:
Returns:
the query part of the uri. For example someparam=32&someotherparam=x
-
Type
-
string
recover(mapper) → {Future}
Handles a failure of this Future by returning the result of another Future.
If the mapper fails, then the returned future will be failed with this failure.
Parameters:
| Name |
Type |
Description |
mapper |
function
|
A function which takes the exception of a failure and returns a new future. |
- Source:
Returns:
A recovered future
-
Type
-
Future
reset(code) → {boolean}
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
When the request has not yet been sent, the request will be aborted and false is returned as indicator.
Parameters:
| Name |
Type |
Description |
code |
number
|
the error code |
- Source:
Returns:
true when reset has been performed
-
Type
-
boolean
result() → {HttpClientResponse}
The result of the operation. This will be null if the operation failed.
- Source:
Returns:
the result or null if the operation failed.
-
Type
-
HttpClientResponse
sendHead(completionHandler) → {HttpClientRequest}
Like 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.
Parameters:
| Name |
Type |
Description |
completionHandler |
function
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
setChunked(chunked) → {HttpClientRequest}
If chunked is true then the request will be set into HTTP chunked mode
Parameters:
| Name |
Type |
Description |
chunked |
boolean
|
true if chunked encoding |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
setFollowRedirects(followRedirects) → {HttpClientRequest}
Parameters:
| Name |
Type |
Description |
followRedirects |
boolean
|
true to follow HTTP redirects |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
setHandler(handler) → {HttpClientRequest}
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
setHost(host) → {HttpClientRequest}
Set the request host.
For HTTP/2 it sets the pseudo header otherwise it sets the header
Parameters:
| Name |
Type |
Description |
host |
string
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
setMaxRedirects(maxRedirects) → {HttpClientRequest}
Set the max number of HTTP redirects this request will follow. The default is 0 which means
no redirects.
Parameters:
| Name |
Type |
Description |
maxRedirects |
number
|
the number of HTTP redirect to follow |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
setRawMethod(method) → {HttpClientRequest}
Set the value the method to send when the method is used.
Parameters:
| Name |
Type |
Description |
method |
string
|
the raw method |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
setStreamPriority(streamPriority) → {HttpClientRequest}
Sets the priority of the associated stream.
This is not implemented for HTTP/1.x.
Parameters:
| Name |
Type |
Description |
streamPriority |
Object
|
the priority of this request's stream |
- Source:
Returns:
-
Type
-
HttpClientRequest
setTimeout(timeoutMs) → {HttpClientRequest}
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.
Parameters:
| Name |
Type |
Description |
timeoutMs |
number
|
The quantity of time in milliseconds. |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpClientRequest
setWriteQueueMaxSize(maxSize) → {HttpClientRequest}
Parameters:
| Name |
Type |
Description |
maxSize |
number
|
|
- Source:
Returns:
-
Type
-
HttpClientRequest
streamId() → {number}
- Source:
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
-
Type
-
number
uri() → {string}
- Source:
Returns:
The URI of the request.
-
Type
-
string
write(chunk, enc, handler)
Same as HttpClientRequest#write but with an handler called when the operation completes
Parameters:
| Name |
Type |
Description |
chunk |
string
|
|
enc |
string
|
|
handler |
function
|
|
- Source:
writeCustomFrame(frame) → {HttpClientRequest}
Like HttpClientRequest#writeCustomFrame but with an HttpFrame.
Parameters:
| Name |
Type |
Description |
frame |
HttpFrame
|
the frame to write |
- Source:
Returns:
-
Type
-
HttpClientRequest
writeQueueFull() → {boolean}
This will return true if there are more bytes in the write queue than the value set using HttpClientRequest#setWriteQueueMaxSize
- Source:
Returns:
true if write queue is full
-
Type
-
boolean