Clients - http : Client

The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it provides includes functions for the standard HTTP methods, forwarding a received request and sending requests using custom HTTP verbs.

Constructor

__init

(string url, ClientEndpointConfig? config)

  • url string
  • URL of the target service

Remote Methods

Fields

  • url string
  • Target service url

  • httpClient HttpClient
  • Chain of different HTTP clients which provides the capability for initiating contact with a remote HTTP service in resilient manner

post

(string path, RequestMessage message)

returns Response | error

The post() function can be used to send HTTP POST requests to HTTP endpoints.

Parameters

  • message RequestMessage
  • An HTTP outbound request message 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

The head() function can be used to send HTTP HEAD requests to HTTP endpoints.

Parameters

  • message RequestMessage - ()
  • An HTTP outbound request message 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

The put() function can be used to send HTTP PUT requests to HTTP endpoints.

Parameters

  • message RequestMessage
  • An HTTP outbound request message 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 httpVerb, string path, RequestMessage message)

returns Response | error

Invokes an HTTP call with the specified HTTP verb.

Parameters

  • httpVerb string
  • HTTP verb value

  • message RequestMessage
  • An HTTP outbound request message 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

The patch() function can be used to send HTTP PATCH requests to HTTP endpoints.

Parameters

  • message RequestMessage
  • An HTTP outbound request message 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

The delete() function can be used to send HTTP DELETE requests to HTTP endpoints.

Parameters

  • message RequestMessage
  • An HTTP outbound request message 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

The get() function can be used to send HTTP GET requests to HTTP endpoints.

Parameters

  • message RequestMessage - ()
  • An optional HTTP outbound request message 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

The options() function can be used to send HTTP OPTIONS requests to HTTP endpoints.

Parameters

  • message RequestMessage - ()
  • An optional HTTP outbound request message 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

The forward() function can be used to invoke an HTTP call with inbound request's HTTP verb

Parameters

  • request Request
  • An HTTP inbound request message

  • 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. The submit() function does not give out a Response as the result, rather it returns an HttpFuture which can be used to do further interactions with the endpoint.

Parameters

  • httpVerb string
  • The HTTP verb value

  • path string
  • The resource path

  • message RequestMessage
  • An HTTP outbound request message 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

This just pass the request to actual network call.

Parameters

  • httpFuture HttpFuture
  • The HttpFuture relates 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

This just pass the request to actual network call.

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

This just pass the request to actual network call.

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

This just pass the request to actual network call.

Parameters

  • Return Type

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

rejectPromise

This just pass the request to actual network call.

Parameters