|
|
@ -45,16 +45,20 @@ QByteArray Http::toByteArray(Response response) |
|
|
|
buf.reserve(1024 + response.content.length()); |
|
|
|
buf.reserve(1024 + response.content.length()); |
|
|
|
|
|
|
|
|
|
|
|
// Status Line
|
|
|
|
// Status Line
|
|
|
|
buf += QString("HTTP/%1 %2 %3") |
|
|
|
buf.append("HTTP/1.1 ") // TODO: depends on request
|
|
|
|
.arg("1.1", // TODO: depends on request
|
|
|
|
.append(QByteArray::number(response.status.code)) |
|
|
|
QString::number(response.status.code), |
|
|
|
.append(' ') |
|
|
|
response.status.text) |
|
|
|
.append(response.status.text.toLatin1()) |
|
|
|
.toLatin1() |
|
|
|
|
|
|
|
.append(CRLF); |
|
|
|
.append(CRLF); |
|
|
|
|
|
|
|
|
|
|
|
// Header Fields
|
|
|
|
// Header Fields
|
|
|
|
for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i) |
|
|
|
for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i) |
|
|
|
buf += QString::fromLatin1("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF); |
|
|
|
{ |
|
|
|
|
|
|
|
buf.append(i.key().toLatin1()) |
|
|
|
|
|
|
|
.append(": ") |
|
|
|
|
|
|
|
.append(i.value().toLatin1()) |
|
|
|
|
|
|
|
.append(CRLF); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// the first empty line
|
|
|
|
// the first empty line
|
|
|
|
buf += CRLF; |
|
|
|
buf += CRLF; |
|
|
|