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, ClientConfiguration? config)

  • url string
  • URL of the target service

Remote Methods

post

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

head

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

put

The Client.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 Client.patch() function can be used to send HTTP PATCH requests to HTTP endpoints.

delete

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

get

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

options

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

forward

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

getResponse

This just pass the request to actual network call.

hasPromise

This just pass the request to actual network call.

getNextPromise

This just pass the request to actual network call.

getPromisedResponse

Passes the request to an actual network call.

rejectPromise

This just pass the request to actual network call.

Methods

Retrieves the cookie store of the client.

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

  • cookieStore CookieStore? (default ())
  • Stores the cookies of the client

post

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 Client.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 http:ClientError if failed to establish communication with the upstream server

put

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 http: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 http:ClientError if failed to establish communication with the upstream server

patch

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 http:ClientError if failed to establish communication with the upstream server

delete

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 http:ClientError if failed to establish communication with the upstream server

get

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 http:ClientError if failed to establish communication with the upstream server

options

(string path, RequestMessage message)

returns Response | ClientError

The Client.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 http:ClientError if failed to establish communication with the upstream server

forward

(string path, Request request)

returns Response | ClientError

The Client.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 http: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 Client->submit() function does not give out a http:Response as the result. Rather it returns an http: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 http:HttpFuture that represents an asynchronous service invocation or else an http:ClientError if the submission fails

getResponse

(HttpFuture httpFuture)

returns Response | ClientError

This just pass the request to actual network call.

Parameters

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

  • Return Type

    (Response | ClientError)
  • An http:Response message or else an http: ClientError if the invocation fails

hasPromise

(HttpFuture httpFuture)

returns boolean

This just pass the request to actual network call.

Parameters

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

  • Return Type

    (boolean)
  • A boolean, which represents whether an http:PushPromise exists

getNextPromise

(HttpFuture httpFuture)

returns PushPromise | ClientError

This just pass the request to actual network call.

Parameters

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

  • Return Type

    (PushPromise | ClientError)
  • An http:PushPromise message or else an http:ClientError if the invocation fails

getPromisedResponse

(PushPromise promise)

returns Response | ClientError

Passes the request to an actual network call.

Parameters

  • Return Type

    (Response | ClientError)
  • A promised http:Response message or else an http:ClientError if the invocation fails

rejectPromise

This just pass the request to actual network call.

Parameters

getCookieStore

()

returns CookieStore?

Retrieves the cookie store of the client.

  • Return Type

    (CookieStore?)
  • The cookie store related to the client