5 #include <QNetworkReply>
6 #include <QNetworkAccessManager>
17 Q_INVOKABLE
explicit VFS_curl(QString url,
bool json=
false,
bool poll=
false,
int expire=10000,
int timeout=60000);
40 virtual QByteArray
icon();
43 virtual QJsonObject
parse(QJsonObject data, QJsonObject &diffout);
63 virtual void sslErrors(QNetworkReply *,
const QList<QSslError> &errors);
VFS_curl reads data from a url when read() is called.
bool _stale
If the retrieved content is stale. Initialized as true.
virtual void read(VFS_request *r)
Request the _url.
bool _json
Interpret fetched data as json.
virtual void sslErrors(QNetworkReply *, const QList< QSslError > &errors)
One or more ssl errors have occurred.
QNetworkReply * _request
The outstanding request, if any.
QJsonObject _data
The data retrieved from a http get request after it has been sent to parse().
virtual bool isContainer()
A VFS_curl node cannot contain children.
bool _poll
If data is considered expired, re-request it.
virtual QByteArray icon()
The "stream" icon found in the VFS_icons library.
virtual QString reportDetails()
Report the url.
virtual void expire()
Set the _stale value to true, and if _poll, request an update.
int _timeout
The time to wait for a response before timing out. Defaults to 60000 ms = 1 minute.
QJsonObject getHeaders(QNetworkReply *reply)
Create a QJsonObject based on a QNetworkReply.
virtual void get(VFS_request *r)
VFS_curl::get.
Q_INVOKABLE VFS_curl(QString url, bool json=false, bool poll=false, int expire=10000, int timeout=60000)
virtual void networkTimeout()
A request was initiated, but timed out.
void replyFinished(QNetworkReply *reply)
A network request has completed.
QTimer _timer
For detecting timeouts on network requests. The QNetworkAccessManager doesn't do this on its own.
QString _reason
If an http request was invalid, this will contain the error string.
QList< VFS_request * > _requests
A list of outstanding VFS_request objects to satisfy once an http request is complete.
virtual QJsonObject parse(QJsonObject data, QJsonObject &diffout)
Parse the incoming data into useful format.
bool _valid
If the http request was valid.
QNetworkAccessManager _manager
The http request manager.
int _expire
Time in milliseconds to consider the retrieved data stale.
QJsonObject _metadata
Certain headers returned from a successful http get request.
bool _getting
If an outstanding request exists.
QUrl _url
The url to request.
virtual void metadata(VFS_request *r)
Fetch the metadata for this node.
VFS_node is the base class from which all other VFS_node classes derive.
The base class for all requests between nodes.