C3Http.Response
Inherits: RefCounted
The response returned by request().
Properties
| Type | Name | Default |
|---|---|---|
bool |
ok |
true |
C3Http.RequestError |
error |
null |
int |
status |
0 |
PackedStringArray |
headers |
PackedStringArray() |
PackedByteArray |
body |
PackedByteArray() |
int |
sse_retry_ms |
-1 |
String |
text |
|
Variant |
json |
Property Descriptions
bool ok = true
true when a response was received with a 2xx status code.
C3Http.RequestError error = null
Error details when ok is false; null otherwise.
int status = 0
HTTP status code, e.g. 200 or 404. 0 when no HTTP response was received (transport failure).
PackedStringArray headers = PackedStringArray()
Response headers as "Name: Value" strings. Empty when no HTTP response was received.
PackedByteArray body = PackedByteArray()
Raw response body bytes. Empty when download_file is set or when no body was received. Use text for a decoded string view.
int sse_retry_ms = -1
The server's last SSE retry: value, in milliseconds — the backoff it suggests before reconnecting. -1 when the stream sent no retry: line or the response was not an SSE stream. Pair it with the last_event_id from on_sse_event to reconnect: wait this long, then re-request with a Last-Event-ID header set to the last id seen.
String text
The response body decoded as UTF-8. Computed lazily on first access and cached, so binary responses never pay the decode cost. Returns "" for an empty or non-UTF-8 body.
Variant json
The response body parsed as JSON. Parsed lazily on first access and cached, reusing the text decode. On a parse failure this pushes an error (once, at parse time) and returns null. Note that a successful parse of a literal JSON null body also returns null.