content: StringHttpResponse
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
contentproperty - Binary responses are available via the
binaryContentproperty - Only one of
contentorbinaryContentwill 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 code returned by the server. Common values: 200 (OK), 404 (Not Found), 500 (Internal Server Error), etc.
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.
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 message if the request failed. This is null for successful requests. Contains details about network errors, timeouts, or other failure reasons.
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.
new(status: Int, content: String, binaryContent: haxe.io.Bytes, ?error: Null<String>, headers: Map): Void| Name | Type | Default | 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> | (optional) | * 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
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 |
|---|---|
:structInit |
- |