HttpResponse

ceramic.HttpResponse (Class)

HTTP response data structure containing the complete response from an HTTP request.

This class encapsulates all data returned from an HTTP request including status codes, response content (both text and binary), headers, and error information. The response automatically handles content type detection and provides the appropriate content format.

Content handling:

  • Text responses (based on MIME type) are available via the content property
  • Binary responses are available via the binaryContent property
  • Only one of content or binaryContent will be non-null based on the response type

Example usage:

Http.request(options, function(response:HttpResponse) {
    if (response.status >= 200 && response.status < 300) {
        if (response.content != null) {
            trace("Text response: " + response.content);
        } else if (response.binaryContent != null) {
            trace("Binary response: " + response.binaryContent.length + " bytes");
        }
    } else {
        trace("Error: " + response.status + " - " + response.error);
    }
});

Instance Members

http
status: Int

HTTP status code returned by the server. Common values: 200 (OK), 404 (Not Found), 500 (Internal Server Error), etc.


http
content: String

Response content as a string for text-based responses. This is null for binary responses or when an error occurred. The content is automatically decoded based on the response's Content-Type header.


http
binaryContent: haxe.io.Bytes

Response content as raw bytes for binary responses. This is null for text-based responses or when an error occurred. Use this for images, files, or other non-text data.


http
error: String

Error message if the request failed. This is null for successful requests. Contains details about network errors, timeouts, or other failure reasons.


http
headers: Map

Map of HTTP response headers with properly formatted keys. Header names are normalized to proper case (e.g., "Content-Type"). Common headers include Content-Type, Content-Length, Set-Cookie, etc.


http
new(status: Int, content: String, binaryContent: haxe.io.Bytes, error: Null<String>, headers: Map): Void
Name Type Description
status Int * HTTP status code returned by the server. Common values: 200 (OK), 404 (Not Found), 500 (Internal Server Error), etc.
content String * Response content as a string for text-based responses. This is null for binary responses or when an error occurred. The content is automatically decoded based on the response's Content-Type header.
binaryContent haxe.io.Bytes * Response content as raw bytes for binary responses. This is null for text-based responses or when an error occurred. Use this for images, files, or other non-text data.
error Null<String> * Error message if the request failed. This is null for successful requests. Contains details about network errors, timeouts, or other failure reasons.
headers Map * Map of HTTP response headers with properly formatted keys. Header names are normalized to proper case (e.g., "Content-Type"). Common headers include Content-Type, Content-Length, Set-Cookie, etc.

Private Members

http
toString(): String

Returns a string representation of this HTTP response for debugging purposes.

Returns Description
String A formatted string showing the response status, content info, headers, and error

Metadata

Name Parameters
:hxGen -
:structInit -