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