new HttpRequestTemplate()
A template for configuring client-side HTTP requests.
Methods
bufferBody() → {HttpResponseTemplate}
Configure to buffer the body and returns a [< Buffer >] HttpResponseTemplate for further configuration of
the response or [#send(Handler) sending] HttpResponseTemplate the request.
Returns:
- Type
- HttpResponseTemplate
host(value) → {HttpRequestTemplate}
Configure the template to use a new host
value
.
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
Returns:
a new
HttpRequestTemplate
instance with the specified host value
- Type
- HttpRequestTemplate
method(value) → {HttpRequestTemplate}
Configure the template to use a new method
value
.
Parameters:
Name | Type | Description |
---|---|---|
value |
Object |
Returns:
a new
HttpRequestTemplate
instance with the specified method value
- Type
- HttpRequestTemplate
port(value) → {HttpRequestTemplate}
Configure the template to use a new port
value
.
Parameters:
Name | Type | Description |
---|---|---|
value |
number |
Returns:
a new
HttpRequestTemplate
instance with the specified port value
- Type
- HttpRequestTemplate
putHeader(name, value) → {HttpRequestTemplate}
Configure the template to add a new HTTP header.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the header name |
value |
string | the header value |
Returns:
a new
HttpRequestTemplate
instance with the specified header
- Type
- HttpRequestTemplate
requestURI(value) → {HttpRequestTemplate}
Configure the template to use a new request URI
value
.
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
Returns:
a new
HttpRequestTemplate
instance with the specified request URI value
- Type
- HttpRequestTemplate
send(handler)
Send a request, the
handler
will receive the response as an .
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
sendBuffer(body, handler)
Like HttpRequestTemplate#send but with an HTTP request
body
buffer.
Parameters:
Name | Type | Description |
---|---|---|
body |
Buffer | the body |
handler |
function |
sendJson(body, handler)
Like HttpRequestTemplate#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 HttpRequestTemplate#send but with an HTTP request
body
stream.
Parameters:
Name | Type | Description |
---|---|---|
body |
ReadStream | the body |
handler |
function |
timeout(value) → {HttpRequestTemplate}
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 new
HttpRequestTemplate
instance with the specified timeout
- Type
- HttpRequestTemplate