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 |
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 |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest
copy() → {HttpRequest}
Copy this request
Returns:
a copy of this request
- 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 |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest
headers() → {MultiMap}
Returns:
The HTTP headers
- Type
- MultiMap
host(value) → {HttpRequest}
Configure the request to use a new host
value
.
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
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 |
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 |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest
putHeader(name, value) → {HttpRequest}
Configure the request to add a new HTTP header.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the header name |
value |
string | the header value |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest
queryParams() → {MultiMap}
Return the current query parameters.
Returns:
the current query parameters
- Type
- MultiMap
send(handler)
Send a request, the
handler
will receive the response as an HttpResponse.
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
sendBuffer(body, handler)
Like HttpRequest#send but with an HTTP request
body
buffer.
Parameters:
Name | Type | Description |
---|---|---|
body |
Buffer | the body |
handler |
function |
sendForm(body, handler)
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 |
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 |
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 |
sendStream(body, handler)
Like HttpRequest#send but with an HTTP request
body
stream.
Parameters:
Name | Type | Description |
---|---|---|
body |
ReadStream | the body |
handler |
function |
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 |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest
ssl(value) → {HttpRequest}
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
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. |
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 |
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpRequest