Clients - http : HttpCachingClient

An HTTP caching client implementation which takes an HttpActions instance and wraps it with an HTTP caching layer.

Constructor

__init

(string url, ClientEndpointConfig config, CacheConfig cacheConfig)

  • url string
  • The URL of the HTTP endpoint to connect to

  • config ClientEndpointConfig
  • The configurations for the client endpoint associated with the caching client

  • cacheConfig CacheConfig
  • The configurations for the HTTP cache to be used with the caching client

Remote Methods

post

Responses returned for POST requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for POST requests invalidate the cached responses for the same resource.

head

Responses for HEAD requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

put

Responses returned for PUT requests are not cacheable. Therefore, the requests are simply directed to the origin server. In addition, PUT requests invalidate the currently stored responses for the given path.

execute

Invokes an HTTP call with the specified HTTP method. This is not a cacheable operation, unless the HTTP method used is GET or HEAD.

patch

Responses returned for PATCH requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for PATCH requests invalidate the cached responses for the same resource.

delete

Responses returned for DELETE requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for DELETE requests invalidate the cached responses for the same resource.

get

Responses for GET requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

options

Responses returned for OPTIONS requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for OPTIONS requests invalidate the cached responses for the same resource.

forward

Forward remote function can be used to invoke an HTTP call with inbound request's HTTP method. Only inbound requests of GET and HEAD HTTP method types are cacheable.

submit

Submits an HTTP request to a service with the specified HTTP verb.

getResponse

Retrieves the Response for a previously submitted request.

hasPromise

Checks whether a PushPromise exists for a previously submitted request.

getNextPromise

Retrieves the next available PushPromise for a previously submitted request.

getPromisedResponse

Retrieves the promised server push Response message.

rejectPromise

Rejects a PushPromise. When a PushPromise is rejected, there is no chance of fetching a promised response using the rejected promise.

Fields

  • url string
  • The URL of the remote HTTP endpoint

  • config ClientEndpointConfig {}
  • The configurations of the client endpoint associated with this CachingActions instance

  • httpClient HttpClient
  • The underlying HttpActions instance which will be making the actual network calls

  • cache HttpCache
  • The cache storage for the HTTP responses

  • cacheConfig CacheConfig {}
  • Configurations for the underlying cache storage and for controlling the HTTP caching behaviour

post

(string path, RequestMessage message)

returns Response | error

Responses returned for POST requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for POST requests invalidate the cached responses for the same resource.

Parameters

  • message RequestMessage
  • HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

Responses for HEAD requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

Parameters

  • message RequestMessage - ()
  • An optional HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

put

(string path, RequestMessage message)

returns Response | error

Responses returned for PUT requests are not cacheable. Therefore, the requests are simply directed to the origin server. In addition, PUT requests invalidate the currently stored responses for the given path.

Parameters

  • message RequestMessage
  • An optional HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

execute

(string httpMethod, string path, RequestMessage message)

returns Response | error

Invokes an HTTP call with the specified HTTP method. This is not a cacheable operation, unless the HTTP method used is GET or HEAD.

Parameters

  • httpMethod string
  • HTTP method to be used for the request

  • message RequestMessage
  • An HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

patch

(string path, RequestMessage message)

returns Response | error

Responses returned for PATCH requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for PATCH requests invalidate the cached responses for the same resource.

Parameters

  • message RequestMessage
  • An HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

delete

(string path, RequestMessage message)

returns Response | error

Responses returned for DELETE requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for DELETE requests invalidate the cached responses for the same resource.

Parameters

  • message RequestMessage
  • An HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

get

(string path, RequestMessage message)

returns Response | error

Responses for GET requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

Parameters

  • message RequestMessage - ()
  • An optional HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

options

(string path, RequestMessage message)

returns Response | error

Responses returned for OPTIONS requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for OPTIONS requests invalidate the cached responses for the same resource.

Parameters

  • message RequestMessage - ()
  • An optional HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

forward

(string path, Request request)

returns Response | error

Forward remote function can be used to invoke an HTTP call with inbound request's HTTP method. Only inbound requests of GET and HEAD HTTP method types are cacheable.

Parameters

  • request Request
  • The HTTP request to be forwarded

  • Return Type

    (Response | error)
  • The response for the request or an error if failed to establish communication with the upstream server

submit

(string httpVerb, string path, RequestMessage message)

returns HttpFuture | error

Submits an HTTP request to a service with the specified HTTP verb.

Parameters

  • httpVerb string
  • The HTTP verb value

  • path string
  • The resource path

  • message RequestMessage
  • An HTTP request or any payload of type string, xml, json, byte[], io:ReadableByteChannel or mime:Entity[]

  • Return Type

    (HttpFuture | error)
  • An HttpFuture that represents an asynchronous service invocation, or an error if the submission fails

getResponse

(HttpFuture httpFuture)

returns Response | error

Retrieves the Response for a previously submitted request.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture related to a previous asynchronous invocation

  • Return Type

    (Response | error)
  • An HTTP response message, or an error if the invocation fails

hasPromise

(HttpFuture httpFuture)

returns boolean

Checks whether a PushPromise exists for a previously submitted request.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture relates to a previous asynchronous invocation

  • Return Type

    (boolean)
  • A boolean that represents whether a PushPromise exists

getNextPromise

(HttpFuture httpFuture)

returns PushPromise | error

Retrieves the next available PushPromise for a previously submitted request.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture relates to a previous asynchronous invocation

  • Return Type

    (PushPromise | error)
  • An HTTP Push Promise message, or an error if the invocation fails

getPromisedResponse

(PushPromise promise)

returns Response | error

Retrieves the promised server push Response message.

Parameters

  • Return Type

    (Response | error)
  • A promised HTTP Response message, or an error if the invocation fails

rejectPromise

Rejects a PushPromise. When a PushPromise is rejected, there is no chance of fetching a promised response using the rejected promise.

Parameters