Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…id=439).

Even without "Content-Type" set to "application/x-www-form-urlencoded", content in the body of a POST or PUT should be available.
  • Loading branch information
detro authored and ariya committed Mar 21, 2012
1 parent 266a12b commit cb02a33
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/webserver.cpp
Expand Up @@ -38,6 +38,7 @@
#include <QThread>
#include <QUrl>
#include <QVector>
#include <QDebug>

namespace UrlEncodedParser {

Expand Down Expand Up @@ -204,9 +205,12 @@ bool WebServer::handleRequest(mg_event event, mg_connection *conn, const mg_requ
char * data = new char[contentLength];
int read = mg_read(conn, data, contentLength);
QByteArray rawData(data, read);
requestObject["rawData"] = rawData;
requestObject["rawData"] = QVariant(rawData);
// Check if the 'Content-Type' requires decoding
if (headersObject["Content-Type"] == "application/x-www-form-urlencoded") {
requestObject["post"] = UrlEncodedParser::parse(rawData);
} else {
requestObject["post"] = QVariant(rawData);
}
delete[] data;
}
Expand Down Expand Up @@ -372,6 +376,7 @@ void WebServerResponse::writeHead(int statusCode, const QVariantMap &headers)
mg_printf(m_conn, "HTTP/1.1 %d %s\r\n", m_statusCode, responseCodeString(m_statusCode));
QVariantMap::const_iterator it = headers.constBegin();
while(it != headers.constEnd()) {
qDebug() << "Response Header key:" << it.key() << "value:" << it.value().toString();
mg_printf(m_conn, "%s: %s\r\n", qPrintable(it.key()), qPrintable(it.value().toString()));
++it;
}
Expand Down

0 comments on commit cb02a33

Please sign in to comment.