4#ifndef MALENA_NETWORKRESPONSE_H
5#define MALENA_NETWORKRESPONSE_H
11#include <unordered_map>
45 std::unordered_map<std::string, std::string>
headers;
56 [[nodiscard]]
bool ok()
const
65 [[nodiscard]]
bool hasHeader(
const std::string& key)
const
75 [[nodiscard]]
const std::string&
header(
const std::string& key,
76 const std::string& fallback =
"")
const
79 return it !=
headers.end() ? it->second : fallback;
The result of an HTTP or WebSocket message.
std::string error
Non-empty when a transport or connection error occurred.
int statusCode
HTTP status code (200, 404, 500 …). 0 on transport/connection failure.
bool hasHeader(const std::string &key) const
Return true when a header with key is present.
std::string body
Response body as a UTF-8 string.
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.
std::unordered_map< std::string, std::string > headers
Response headers, lower-cased keys.