The result of an HTTP or WebSocket message. More...
#include <Malena/Engine/Networking/NetworkResponse.h>
Public Member Functions | |
| bool | hasHeader (const std::string &key) const |
Return true when a header with key is present. | |
| const std::string & | header (const std::string &key, const std::string &fallback="") const |
Return the value of header key, or fallback if absent. | |
| bool | ok () const |
Return true when the request succeeded with a 2xx status. | |
Public Attributes | |
| std::string | body |
| Response body as a UTF-8 string. | |
| std::string | error |
| Non-empty when a transport or connection error occurred. | |
| std::unordered_map< std::string, std::string > | headers |
| Response headers, lower-cased keys. | |
| int | statusCode = 0 |
| HTTP status code (200, 404, 500 …). 0 on transport/connection failure. | |
The result of an HTTP or WebSocket message.
Returned to every HttpClient callback and carried by WebSocketClient message events. Check ok() before accessing body — if the transport failed, error describes the reason and statusCode is 0.
Definition at line 36 of file NetworkResponse.h.
|
inlinenodiscard |
Return true when a header with key is present.
| key | Header name (case-insensitive — stored lower-cased). |
Definition at line 65 of file NetworkResponse.h.
|
inlinenodiscard |
Return the value of header key, or fallback if absent.
| key | Header name (case-insensitive). |
| fallback | Value returned when the header is not present. |
Definition at line 75 of file NetworkResponse.h.
|
inlinenodiscard |
Return true when the request succeeded with a 2xx status.
A response is considered successful when there is no transport error and the HTTP status is in the [200, 299] range.
Definition at line 56 of file NetworkResponse.h.
| std::string ml::NetworkResponse::body |
Response body as a UTF-8 string.
Definition at line 42 of file NetworkResponse.h.
| std::string ml::NetworkResponse::error |
Non-empty when a transport or connection error occurred.
Definition at line 48 of file NetworkResponse.h.
| std::unordered_map<std::string, std::string> ml::NetworkResponse::headers |
Response headers, lower-cased keys.
Definition at line 45 of file NetworkResponse.h.
| int ml::NetworkResponse::statusCode = 0 |
HTTP status code (200, 404, 500 …). 0 on transport/connection failure.
Definition at line 39 of file NetworkResponse.h.