class

JSON::RPC::HTTPTransport

Inherits JSON::RPC::Transport < Reference < Object

The default transport: POSTs each request to a fixed HTTP endpoint.

Subclass and override {#call} (or {#post}) to layer in behavior such as CSRF token handling or automatic re-authentication.

Constructors

new(uri : String | URI, headers : HTTP::Headers = HTTP::Headers.new)
Source

Instance methods

basic_auth(user : String, password : String) : Nil

Adds HTTP Basic authentication credentials to every request.

Source
call(body : String) : String

Sends body (a serialized JSON-RPC request) and returns the raw response body. Must raise {TransportError} on any transport-level failure.

Source
headers

Headers sent with every request. Mutable so subclasses and callers can adjust authentication or session tokens between calls.

Source
headers=(headers : HTTP::Headers)

Headers sent with every request. Mutable so subclasses and callers can adjust authentication or session tokens between calls.

Source

Performs the raw HTTP POST. Exposed as a seam for subclasses that need to inspect or retry the response (e.g. CSRF token negotiation).

Source
uri

The endpoint requests are POSTed to.

Source