PDA

View Full Version : Sample of Http server



Lele
26th January 2009, 09:04
Hi,
I'm looking for a sample of an http server written in QT that has just to receive a POST with a JPG image and send back another JPG image.
At the moment I set up a QTcpServer that can accept the connection



QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
connect(clientConnection, SIGNAL(disconnected()),
clientConnection, SLOT(deleteLater()));

clientConnection->waitForReadyRead(2000);
qint64 byteAvail = clientConnection->bytesAvailable();


And I see I'm getting there are bytes available to read,
so my questions:

- Is there some sample aroung a bout implementing an HTTP Server ?
- How can I get the data and unwrap the HTTP packet, just when I know I received all?

Thanks a lot in advance
Bye

Lele
26th January 2009, 16:25
There's really no way to parse a HTTP POST request retrieving the jpg image?
Thanks

David_G_Ortega
30th November 2010, 23:43
I wrote a LOOOOONG post about this explaining a lot of things but I lost the session and I posted LOOSING all the post :mad:, so the short answer is


QTcpSocket* socket = (QTcpSocket*)sender();
QString text;
while(socket->bytesAvailable() || socket->canReadLine())
{
text += socket->readLine();
}