Making webserver module read request bodies and write response bodies using UTF-8

1.8
Jim Evans 2012-09-28 12:17:02 -04:00 committed by Ivan De Marino
parent 395af9cada
commit 42bf8b36d8
1 changed files with 3 additions and 3 deletions

View File

@ -221,9 +221,9 @@ bool WebServer::handleRequest(mg_event event, mg_connection *conn, const mg_requ
// Check if the 'Content-Type' requires decoding
if (headersObject["Content-Type"] == "application/x-www-form-urlencoded") {
requestObject["post"] = UrlEncodedParser::parse(QByteArray(data, read));
requestObject["postRaw"] = QString::fromLocal8Bit(data, read);
requestObject["postRaw"] = QString::fromUtf8(data, read);
} else {
requestObject["post"] = QString::fromLocal8Bit(data, read);
requestObject["post"] = QString::fromUtf8(data, read);
}
delete[] data;
} else {
@ -405,7 +405,7 @@ void WebServerResponse::write(const QString &body)
writeHead(m_statusCode, m_headers);
}
///TODO: encoding?!
const QByteArray data = body.toLocal8Bit();
const QByteArray data = body.toUtf8();
mg_write(m_conn, data.constData(), data.size());
}