HttpAgent 

Kind: global interface


httpAgent.get(url, data, [options]) ⇒ Promise.<Response> 

Sends an HTTP GET request to the specified URL, sending the provided data as query parameters.

Kind: instance method of HttpAgent
Returns: Promise.<Response> - A promise that resolves to the response.

Param Type Description
url string The URL to which the request should be made.
data Object.<string, (boolean\|number\|string)> The data to send to the server as query parameters.
[options] RequestOptions Optional request options.

httpAgent.post(url, data, [options]) ⇒ Promise.<Response> 

Sends an HTTP POST request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Kind: instance method of HttpAgent
Returns: Promise.<Response> - A promise that resolves to the response.

Param Type Description
url string The URL to which the request should be made.
data string | Object.<string, \*> The data to send to the server as the request body.
[options] RequestOptions Optional request options.

httpAgent.put(url, data, [options]) ⇒ Promise.<Response> 

Sends an HTTP PUT request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Kind: instance method of HttpAgent
Returns: Promise.<Response> - A promise that resolves to the response.

Param Type Description
url string The URL to which the request should be made.
data string | Object.<string, \*> The data to send to the server as the request body.
[options] RequestOptions Optional request options.

httpAgent.patch(url, data, [options]) ⇒ Promise.<Response> 

Sends an HTTP PATCH request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Kind: instance method of HttpAgent
Returns: Promise.<Response> - A promise that resolves to the response.

Param Type Description
url string The URL to which the request should be made.
data string | Object.<string, \*> The data to send to the server as the request body.
[options] RequestOptions Optional request options.

httpAgent.delete(url, data, [options]) ⇒ Promise.<Response> 

Sends an HTTP DELETE request to the specified URL, sending the provided data as the request body. If an object is provided as the request data, the data will be JSON-encoded. Sending other primitive non-string values as the request body is not supported.

Kind: instance method of HttpAgent
Returns: Promise.<Response> - A promise that resolves to the response.

Param Type Description
url string The URL to which the request should be made.
data string | Object.<string, \*> The data to send to the server as the request body.
[options] RequestOptions Optional request options.

httpAgent.getCacheKey(method, url, data) ⇒ string 

Generates a cache key to use for identifying a request to the specified URL using the specified HTTP method, submitting the provided data.

Kind: instance method of HttpAgent
Returns: string - The key to use for identifying such a request in the cache.

Param Type Description
method string The HTTP method used by the request.
url string The URL to which the request is sent.
data Object.<string, string> The data associated with the request. These can be either the query parameters or request body data.

httpAgent.setDefaultHeader(header, value) ⇒ HttpAgent 

Sets the specified header to be sent with every subsequent HTTP request, unless explicitly overridden by request options.

Kind: instance method of HttpAgent
Returns: HttpAgent - This HTTP agent.

Param Type Description
header string The name of the header.
value string The header value. To provide multiple values, separate them with commas (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2).

httpAgent.clearDefaultHeaders() ⇒ HttpAgent 

Clears all configured default headers.

Kind: instance method of HttpAgent
Returns: HttpAgent - This HTTP agent.


HttpAgent~RequestOptions : Object 

Options for a request sent using the HTTP agent.

Kind: inner typedef of HttpAgent
Properties

Name Type Description
[timeout] number Specifies the request timeout in milliseconds.
[ttl] number Specified how long the request may be cached in milliseconds.
[repeatRequest] number Specifies the maximum number of tries to repeat the request if the request fails.
[headers] Object.<string, string> Sets the additional request headers (the keys are case-insensitive header names, the values are header values).
[fetchOptions] Object.<string, \*> Sets the fetch request options.
[cache] boolean Flag that enables caching the HTTP request (enabled by default, also applies to requests in progress).
[withCredentials] boolean Flag that indicates whether the request should be made using credentials such as cookies or authorization headers.
[listeners] Object Listeners for request events.
[postProcessor] function Response post-processor applied just before the response is stored in the cache and returned.

HttpAgent~Response : Object 

A response from the server.

Kind: inner typedef of HttpAgent
Properties

Name Type Description
status number The HTTP response status code.
body \* The parsed response body, parsed as JSON.
params HttpProxy~RequestParams The original request params.
headers Object.<string, string> The response HTTP headers.
cached boolean Whether or not the response has been cached.