Skip to main content

Module http

Module http 

Source
Expand description

HTTP utilities for CBOR and Candid RPC calls.

This module provides functionality for:

  • Making CBOR-encoded RPC calls;
  • Making Candid-encoded canister calls;
  • Handling HTTP requests and responses;
  • Error handling for RPC operations.

The main types are:

  • RPCRequest: Represents a generic RPC request with CBOR-encoded parameters;
  • CanisterRequestRef: Represents a canister-specific request with Candid-encoded parameters;
  • RPCResponse: Represents a response from an RPC call;
  • HttpRPCError: Represents possible errors during RPC operations.

The main functions are:

  • http_rpc: Makes a generic CBOR-encoded RPC call;
  • canister_rpc: Makes a canister-specific RPC call with Candid encoding;
  • cbor_rpc: Internal function for making CBOR-encoded HTTP requests.

Structs§

CanisterRequestRef
Borrowed request to an ICP canister with Candid-encoded parameters.
ListObject
Paginated list response.
RPCRequest
Owned RPC request with a method name and CBOR-encoded parameters.
RPCRequestRef
Borrowed RPC request with a method name and CBOR-encoded parameters.

Enums§

HttpRPCError
Errors returned by http_rpc, canister_rpc, and cbor_rpc.

Constants§

CONTENT_TYPE_CBOR
MIME type used for CBOR-encoded RPC request and response bodies.
CONTENT_TYPE_JSON
MIME type used for JSON HTTP request and response bodies.
CONTENT_TYPE_TEXT
MIME type used for plain text HTTP response bodies.
MAX_RPC_RESPONSE_BYTES
Maximum size, in bytes, accepted for a CBOR RPC success response body.

Functions§

canister_rpc
Calls a canister method through a remote endpoint using Candid-encoded arguments.
cbor_rpc
Sends a raw CBOR RPC request and returns the remote payload.
http_rpc
Calls a remote CBOR RPC method and decodes its CBOR response payload.

Type Aliases§

RPCResponse
RPC response payload returned by remote engines.