From b6d13a3ac7797474f4bfec7ba13481807ed38251 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Tue, 20 Mar 2012 23:58:13 +0000 Subject: [PATCH] Fix for Issue [439](http://code.google.com/p/phantomjs/issues/detail?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. --- src/webserver.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/webserver.cpp b/src/webserver.cpp index 95f895bc..1c059273 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace UrlEncodedParser { @@ -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; } @@ -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; }