http: Implement HTTPResponse class

HTTP Response message:
https://datatracker.ietf.org/doc/html/rfc1945#section-6

Status line (first line of response):
https://datatracker.ietf.org/doc/html/rfc1945#section-6.1

Status code definitions:
https://datatracker.ietf.org/doc/html/rfc1945#section-9
This commit is contained in:
Matthew Zipkin
2024-10-16 10:57:06 -04:00
parent 68b5d289d1
commit ad50aa4a0f
4 changed files with 76 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include <span>
#include <string>
#include <rpc/protocol.h>
#include <util/strencodings.h>
#include <util/string.h>
@@ -234,6 +235,29 @@ private:
*/
std::vector<std::pair<std::string, std::string>> m_headers;
};
struct HTTPVersion {
/**
* Default HTTP protocol version 1.1 is used by error responses
* when a request is unreadable.
*/
/// @{
uint8_t major{1};
uint8_t minor{1};
/// @}
};
class HTTPResponse
{
public:
HTTPVersion m_version;
HTTPStatusCode m_status{HTTP_INTERNAL_SERVER_ERROR};
HTTPHeaders m_headers;
std::string StringifyHeaders() const;
};
} // namespace http_bitcoin
#endif // BITCOIN_HTTPSERVER_H