Clients - http : HttpClient

Provides the HTTP actions for interacting with an HTTP server. Apart from the standard HTTP methods, forward() and execute() functions are provided. More complex and specific endpoint types can be created by wrapping this generic HTTP actions implementation.

Constructor

__init

(string url, ClientConfiguration? config)

  • url string

Remote Methods

post

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

head

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

put

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

execute

Invokes an HTTP call with the specified HTTP verb.

patch

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

delete

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

get

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

options

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

forward

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

submit

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.

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

post

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • 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

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

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

Parameters

  • path string
  • Resource path

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

  • Return Type

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

put

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • 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

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

execute

(string httpVerb, string path, RequestMessage message)

returns Response | ClientError

Invokes an HTTP call with the specified HTTP verb.

Parameters

  • httpVerb string
  • HTTP verb value

  • path string
  • 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

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

patch

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • 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

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

delete

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • Resource path

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

  • Return Type

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

get

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • Request path

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

  • Return Type

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

options

(string path, RequestMessage message)

returns Response | ClientError

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

Parameters

  • path string
  • Request path

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

  • Return Type

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

forward

(string path, Request request)

returns Response | ClientError

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

Parameters

  • path string
  • Request path

  • request Request
  • An HTTP inbound request message

  • Return Type

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

submit

(string httpVerb, string path, RequestMessage message)

returns HttpFuture | ClientError

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 | ClientError)
  • An HttpFuture that represents an asynchronous service invocation, or an ClientError if the submission fails

getResponse

(HttpFuture httpFuture)

returns Response | ClientError

Retrieves the Response for a previously submitted request.

Parameters

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

  • Return Type

    (Response | ClientError)
  • An HTTP response message, or an ClientError 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 | ClientError

Retrieves the next available PushPromise for a previously submitted request.

Parameters

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

  • Return Type

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

getPromisedResponse

(PushPromise promise)

returns Response | ClientError

Retrieves the promised server push Response message.

Parameters

  • Return Type

    (Response | ClientError)
  • A promised HTTP Response message, or an ClientError 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