Files
cantata/web/http/httpconnection.h
Craig Drummond 59e329d3e9 Initial import of *VERY* incomplete, and not fully functional Cantata
webapp. Mainly used to test SQLite backend for storing MPD db.
2015-06-01 22:57:49 +01:00

53 lines
1001 B
C++

/**
* @file
*
* @author Stefan Frings
* @author Petr Bravenec petr.bravenec@hobrasoft.cz
* @author Craig Drummond
*/
#ifndef HTTP_CONNECTION_H
#define HTTP_CONNECTION_H
#include <QObject>
#include <QTcpSocket>
#include <QTimer>
#include "httprequest.h"
#include "httpresponse.h"
class BasicHttpServer;
class HttpRequestHandler;
class HttpConnection : public QObject
{
Q_OBJECT
public:
HttpConnection(BasicHttpServer *parent, QTcpSocket *sock);
~HttpConnection();
void close();
void disconnectFromHost() { socket->disconnectFromHost(); }
bool isConnected() const { return socket->isOpen(); }
private:
void write(const QByteArray &data);
void requestHandled();
private Q_SLOTS:
void timeout();
void readData();
void disconnected();
private:
QTcpSocket *socket;
QTimer *timer;
HttpRequest request;
HttpResponse response;
BasicHttpServer *server;
HttpRequestHandler *handler;
friend class HttpResponse;
};
#endif