35 , _httpd(&_socket,port, this)
94 MIME_TYPES.insert(
"eot",
"application/vnd.ms-fontobject");
96 MIME_TYPES.insert(
"ttf",
"application/x-font-ttf");
114 connect( &
_httpd, SIGNAL( newRequest(QHttpRequest*, QHttpResponse*) ),
115 this, SLOT(
handle(QHttpRequest*, QHttpResponse*) ) );
138 while(
_socket.hasPendingConnections())
140 QTcpSocket *s =
_socket.nextPendingConnection();
150 QHttpConnection *connection =
new QHttpConnection(s, &
_httpd);
151 connect(connection, SIGNAL(newRequest(QHttpRequest *, QHttpResponse *)),
152 &
_httpd, SIGNAL(newRequest(QHttpRequest *, QHttpResponse *)) );
170 VFS::LOG( QString(
"HTTP Request: %1").arg(req->url().toString()) );
238 VFS::WARN(
"HTTPD Responder should be overridden in a subclass... Responding with error page.");
284 printf(
" Accumulated: %s",qUtf8Printable(data));
298 QString s = QString(
"%1: %2").arg(
_status).arg(STATUS_CODES.value(
_status));
299 QString r = QString(
"Requested: %1<br><i>Serving on port %2</i>").arg(
_url.toString()).arg(
_url.port());
300 QString e = QString(
"<html><head><title>%1</title></head><body><h1>%1</h1>%2</body></html>\n").arg(s).arg(r);
Holds the request and response objects for future use.
QHttpResponse * _m_resp
http response object
virtual void accumulate(const QByteArray &)
This seems to be used during an http push request.
QString _path
path component of url
VFS_httpd_responder(QHttpRequest *req, QHttpResponse *resp)
QHttpRequest * _m_req
http request object
virtual QByteArray errorPage()
The default error page.
virtual ~VFS_httpd_responder()
VFS_httpd_responder destructor.
virtual void validatePath(QUrl url)
Validates the incoming path.
virtual void respond()
Send an http response back to the client.
VFS_httpd(quint16 port, QHostAddress addr=QHostAddress::Any, bool ssl=false, QString sslCertPath="", QString sslKeyPath="")
VFS_httpd constructor.
virtual bool isContainer()
A VFS_httpd node cannot contain children.
QHttpServer _httpd
QHttpServer instance.
virtual void createNewConnection()
The server has received a new http connection request.
virtual void handle(QHttpRequest *req, QHttpResponse *resp)
Handle an incoming http request.
void initMimes()
Initialize the mime map.
virtual bool listen()
Start listening for incoming connections.
static QHash< QString, QString > MIME_TYPES
The mime type map.
QString className()
Return the class name of a node.
Open a listening TCP port for other clients to connect to.
virtual bool listen()
Open the server socket and listen for new connections.
VFSQTcpServer _socket
TCP socket used for connections.
quint16 _port
TCP port to listen on, or 0 to find an available one.
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
static void ERROR(QString message, int level=0, QString user="server")
Send a message to the VFS::_errors VFS_stream.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.