new HttpRequest()
A client-side HTTP request.
- Source:
Methods
addQueryParam(paramName, paramValue) → {HttpRequest}
Add a query parameter to the request.
Parameters:
| Name |
Type |
Description |
paramName |
string
|
the param name |
paramValue |
string
|
the param value |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
as(responseCodec) → {HttpRequest}
Configure the request to decode the response with the responseCodec.
Parameters:
| Name |
Type |
Description |
responseCodec |
BodyCodec
|
the response codec |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
basicAuthentication(id, password) → {HttpRequest}
Configure the request to perform basic access authentication.
In basic HTTP authentication, a request contains a header field of the form 'Authorization: Basic <credentials>',
where credentials is the base64 encoding of id and password joined by a colon.
Parameters:
| Name |
Type |
Description |
id |
Buffer
|
the id |
password |
Buffer
|
the password |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
bearerTokenAuthentication(bearerToken) → {HttpRequest}
Configure the request to perform bearer token authentication.
In OAuth 2.0, a request contains a header field of the form 'Authorization: Bearer <bearerToken>',
where bearerToken is the bearer token issued by an authorization server to access protected resources.
Parameters:
| Name |
Type |
Description |
bearerToken |
string
|
the bearer token |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
copy() → {HttpRequest}
Copy this request
- Source:
Returns:
a copy of this request
-
Type
-
HttpRequest
expect(predicate) → {HttpRequest}
Add an expectation that the response is valid according to the provided
predicate.
Multiple predicates can be added.
Parameters:
| Name |
Type |
Description |
predicate |
ResponsePredicate
|
the predicate |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
followRedirects(value) → {HttpRequest}
Set wether or not to follow the directs for the request.
Parameters:
| Name |
Type |
Description |
value |
boolean
|
true if redirections should be followed |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
- Source:
Returns:
The HTTP headers
-
Type
-
MultiMap
host(value) → {HttpRequest}
Configure the request to use a new host value.
Parameters:
| Name |
Type |
Description |
value |
string
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
method(value) → {HttpRequest}
Configure the request to use a new method value.
Parameters:
| Name |
Type |
Description |
value |
Object
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
multipartMixed(allow) → {HttpRequest}
Allow or disallow multipart mixed encoding when sending having files sharing the same
file name.
The default value is
true.
Set to
false if you want to achieve the behavior for
HTML5.
Parameters:
| Name |
Type |
Description |
allow |
boolean
|
true allows use of multipart mixed encoding |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
port(value) → {HttpRequest}
Configure the request to use a new port value.
Parameters:
| Name |
Type |
Description |
value |
number
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
Configure the request to add a new 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
-
HttpRequest
Configure the request to add multiple HTTP headers .
Parameters:
| Name |
Type |
Description |
headers |
MultiMap
|
The HTTP headers |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
queryParams() → {MultiMap}
Return the current query parameters.
- Source:
Returns:
the current query parameters
-
Type
-
MultiMap
rawMethod(method) → {HttpRequest}
Configure the request to use a custom HTTP method
Parameters:
| Name |
Type |
Description |
method |
string
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
send(handler)
Send a request, the handler will receive the response as an HttpResponse.
Parameters:
| Name |
Type |
Description |
handler |
function
|
|
- Source:
sendBuffer(body, handler)
Like HttpRequest#send but with an HTTP request body buffer.
Parameters:
| Name |
Type |
Description |
body |
Buffer
|
the body |
handler |
function
|
|
- Source:
Like HttpRequest#send but with an HTTP request
body multimap encoded as form and the content type
set to
application/x-www-form-urlencoded.
When the content type header is previously set to multipart/form-data it will be used instead.
Parameters:
| Name |
Type |
Description |
body |
MultiMap
|
the body |
handler |
function
|
|
- Source:
sendJson(body, handler)
Like HttpRequest#send but with an HTTP request body object encoded as json and the content type
set to application/json.
Parameters:
| Name |
Type |
Description |
body |
Object
|
the body |
handler |
function
|
|
- Source:
sendJsonObject(body, handler)
Like HttpRequest#send but with an HTTP request body object encoded as json and the content type
set to application/json.
Parameters:
| Name |
Type |
Description |
body |
Object
|
the body |
handler |
function
|
|
- Source:
Like HttpRequest#send but with an HTTP request body multimap encoded as form and the content type
set to multipart/form-data. You may use this method to send attributes and upload files.
Parameters:
| Name |
Type |
Description |
body |
MultipartForm
|
the body |
handler |
function
|
|
- Source:
sendStream(body, handler)
Like HttpRequest#send but with an HTTP request body stream.
Parameters:
| Name |
Type |
Description |
body |
ReadStream
|
the body |
handler |
function
|
|
- Source:
setQueryParam(paramName, paramValue) → {HttpRequest}
Set a query parameter to the request.
Parameters:
| Name |
Type |
Description |
paramName |
string
|
the param name |
paramValue |
string
|
the param value |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
ssl(value) → {HttpRequest}
Parameters:
| Name |
Type |
Description |
value |
boolean
|
|
- Source:
Returns:
-
Type
-
HttpRequest
timeout(value) → {HttpRequest}
Configures the amount of time in milliseconds after which if the request does not return any data within the timeout
period an TimeoutException fails the request.
Setting zero or a negative value disables the timeout.
Parameters:
| Name |
Type |
Description |
value |
number
|
The quantity of time in milliseconds. |
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
uri(value) → {HttpRequest}
Configure the request to use a new request URI
value.
When the uri has query parameters, they are set in the HttpRequest#queryParams multimap, overwritting
any parameters previously set.
Parameters:
| Name |
Type |
Description |
value |
string
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest
virtualHost(value) → {HttpRequest}
Configure the request to use a virtual host
value.
Usually the header
host (
:authority pseudo header for HTTP/2) is set from the request host value
since this host value resolves to the server IP address.
Sometimes you need to set a host header for an address that does not resolve to the server IP address.
The virtual host value overrides the value of the actual
host header (
:authority pseudo header
for HTTP/2).
The virtual host is also be used for SNI.
Parameters:
| Name |
Type |
Description |
value |
string
|
|
- Source:
Returns:
a reference to this, so the API can be used fluently
-
Type
-
HttpRequest