#include <xrserver.h>
Inheritance diagram for XRServer:
Public Slots | |
void | sendMethodResponse (int req, const QVariant &result) |
void | sendFault (int req, int fault_code, const QString &fault_string) |
Signals | |
void | methodCall (int req, const QString &methodname, const QValueList< QVariant > ¶ms, bool &handled) |
Public Methods | |
XRServer (Q_UINT16 port=8080, int backlog=1, QObject *parent=0, const char *name=0) | |
~XRServer () | |
QHostAddress | getPeerForRequest (int req) const |
Protected Slots | |
void | readFromClient () |
void | deleteClient () |
Protected Methods | |
void | newConnection (int socket) |
void | parseContentAndEmit (QSocket *s) |
void | sendHttpError (QSocket *s, int status_code, const QString &reason, QString resp) |
void | sendHttpResponse (QSocket *s, int status_code, const QString &reason, QHttpHeader &headers, QString resp) |
Protected Attributes | |
QMap< QSocket *, QString > | _header_strings |
QMap< QSocket *, QHttpRequestHeader > | _headers |
QMap< QSocket *, bool > | _open_sockets |
QMap< int, QSocket * > | _req_to_socket |
int | _last_req |
|
Create an xml-rpc server on given port.
|
|
Delete (which closes) all the sockets immediately. Does not do any graceful closing of the HTTP connections. |
|
The constructor connects this slot to QServerSocket::delayedCloseFinished() |
|
Lightweight authentication function. Useful if you only want certain hosts to be able to call a method. Returns 0.0.0.0 if the request is not an active request.
|
|
This signal is emitted when a new method call comes in. Handlers should connect to this signal. Qt's signal and slot mechanism will make sure it gets to all handlers. Each handler is responsible for checking the method name and seeing if this is a request they should handle. If they do, they set handled to true.
|
|
|
|
|
|
The constructor connects this slot to QServerSocket::readyRead() |
|
When a methodCall is handled with an unsuccessful (fault) result, this slot is used to send the fault back to the caller. Either this, or XRServer::sendMethodResponse may be called, but not both.
|
|
Convienience function to handle the HTTP transport. |
|
Convienience function to handle the HTTP transport. Used to send responses and faults
|
|
When a methodCall is handled with a successful (non-fault) result, this slot is used to send the response back to the caller. Either this, or XRServer::sendFault may be called, but not both.
|
|
Until we read all the headers, each time we can read data, we check to see if we can read an entire line. If we can, we append to header strings recieved so far. When we get an empty line (which in HTTP means the headers are over) we create an HttpRequestHeader and add it to _headers |
|
Stores the complete headers for the current request from a socket. If there is not current request, this map will have no entry for the socket. In this way, it also represents a set of sockets that have active requests. |
|
Counter that increases with each request. |
|
Since QT does not have a Set object, and we don't want to introduce an STL dependence for one class, we hack QMap to be a set of open sockets. When the destructor is called, all these sockets are deleted. |
|
Keeps track of requests for each socket. |