NoRulez
27th May 2008, 14:17
Hey @all,
I'm using QTcpServer as my HTTPServer. When I get a HTTP GET Request all working fine, but how I can handle a HTTP POST Request?
Here is the code where i read from the client:
void HttpServer::readClient() {
if (disabled)
return;
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket->canReadLine()) {
QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
qDebug() << "QStringList ---------";
for (QList<QString>::iterator i = tokens.begin(); i != tokens.end(); ++i)
qDebug() << (*i);
}
}
What I see with a GET Request (http://127.0.0.1:84/index.html?firstname=Max&lastname=Mustermann):
QStringList ---------
"GET"
"/index.html?firstname=Max&lastname=Mustermann"
"HTTP/1.1"
""
And here i see something about the POST REQUEST (http://127.0.0.1:84/index.html):
QStringList ---------
"POST"
"/"
"HTTP/1.0"
""
How can i read POST Variables?
Regards
NoRulez
I'm using QTcpServer as my HTTPServer. When I get a HTTP GET Request all working fine, but how I can handle a HTTP POST Request?
Here is the code where i read from the client:
void HttpServer::readClient() {
if (disabled)
return;
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket->canReadLine()) {
QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
qDebug() << "QStringList ---------";
for (QList<QString>::iterator i = tokens.begin(); i != tokens.end(); ++i)
qDebug() << (*i);
}
}
What I see with a GET Request (http://127.0.0.1:84/index.html?firstname=Max&lastname=Mustermann):
QStringList ---------
"GET"
"/index.html?firstname=Max&lastname=Mustermann"
"HTTP/1.1"
""
And here i see something about the POST REQUEST (http://127.0.0.1:84/index.html):
QStringList ---------
"POST"
"/"
"HTTP/1.0"
""
How can i read POST Variables?
Regards
NoRulez