Http

ceramic.Http (Class)

A cross-platform and high level HTTP request utility that provides a unified interface for making HTTP requests across all supported Ceramic platforms.

This class serves as the main entry point for HTTP networking in Ceramic applications, providing automatic header formatting, parameter encoding, and response processing.

Features:

  • Cross-platform HTTP requests (web, mobile, desktop, Unity)
  • Automatic parameter encoding for GET and POST requests
  • Header normalization and formatting
  • Support for both text and binary responses
  • Timeout handling
  • Content-Length automatic calculation
  • Support for multiple headers with the same key via HttpHeaders

Example usage:

Http.request({
    url: "https://api.example.com/data",
    method: GET,
    params: ["key" => "value"],
    headers: ["Authorization" => "Bearer token"],
    timeout: 30
}, function(response) {
    if (response.status == 200) {
        trace("Success: " + response.content);
    } else {
        trace("Error: " + response.error);
    }
});

Static Members

http
request(options: HttpRequestOptions, done: Function): Void

Performs an HTTP request with the specified options.

This method handles the complete HTTP request lifecycle including:

  • Header formatting and normalization
  • Parameter encoding for GET/POST requests
  • Content-Length calculation
  • Response processing and cleanup
Name Type Description
options HttpRequestOptions The HTTP request configuration including URL, method, headers, parameters, and timeout
done Function Callback function that receives the HTTP response when the request completes