Define and use a proper HTTP header structure

This commit is contained in:
Chocobo1
2020-05-10 02:48:21 +08:00
parent 957d697aee
commit 74a2168bc1
5 changed files with 16 additions and 17 deletions

View File

@@ -35,9 +35,9 @@ void ResponseBuilder::status(const uint code, const QString &text)
m_response.status = {code, text};
}
void ResponseBuilder::header(const QString &name, const QString &value)
void ResponseBuilder::header(const Header &header)
{
m_response.headers[name] = value;
m_response.headers[header.name] = header.value;
}
void ResponseBuilder::print(const QString &text, const QString &type)

View File

@@ -37,7 +37,7 @@ namespace Http
{
public:
void status(uint code = 200, const QString &text = QLatin1String("OK"));
void header(const QString &name, const QString &value);
void header(const Header &header);
void print(const QString &text, const QString &type = CONTENT_TYPE_HTML);
void print(const QByteArray &data, const QString &type = CONTENT_TYPE_HTML);
void clear();

View File

@@ -92,6 +92,12 @@ namespace Http
QByteArray data;
};
struct Header
{
QString name;
QString value;
};
struct Request
{
QString version;