|
swift
|
Utilities, e.g. checking whether a network connection can be established. More...
#include <networkutils.h>
Public Types | |
| enum | RequestType { Get , PostUrlEncoded , Multipart } |
| Request type. More... | |
Static Public Member Functions | |
| static int | getTimeoutMs () |
| Default for timeout. | |
| static int | getLongTimeoutMs () |
| Default for timeout (long). | |
| static bool | canConnect (const QString &hostAddress, int port, QString &message, int timeoutMs=getTimeoutMs()) |
| Can connect? | |
| static bool | canConnect (const swift::misc::network::CServer &server, QString &message, int timeoutMs=getTimeoutMs()) |
| Can connect to server? | |
| static bool | canConnect (const QString &url, QString &message, int timeoutMs=getTimeoutMs()) |
| Can connect to URL? | |
| static bool | canConnect (const QUrl &url, QString &message, int timeoutMs=getTimeoutMs()) |
| Can connect to URL? | |
| static bool | canConnect (const QUrl &url, int timeoutMs=getTimeoutMs()) |
| Can connect to URL? | |
| static QStringList | getKnownLocalIpV4Addresses () |
| Find out my IPv4 addresses including loopback, empty if not possible. | |
| static bool | isValidIPv4Address (const QString &candidate) |
| Valid IPv4 address. | |
| static bool | isValidIPv6Address (const QString &candidate) |
| Valid IPv6 address. | |
| static bool | isValidPort (const QString &port) |
| Valid port. | |
| static QString | buildUrl (const QString &protocol, const QString &server, const QString &baseUrl, const QString &serviceUrl) |
| Build / concatenate an URL. | |
| static void | setSwiftUserAgent (QNetworkRequest &request, const QString &userAgentDetails={}) |
| Set user agent for request. | |
| static void | addDebugFlag (QUrlQuery &qurl) |
| Add debug flag. | |
| static QNetworkRequest | getSwiftNetworkRequest (const QUrl &url, RequestType type=Get, const QString &userAgentDetails={}) |
| Our tweaked network request with swift header. | |
| static QNetworkRequest | getSwiftNetworkRequest (const QNetworkRequest &request, const QString &userAgentDetails={}) |
| Get a copied network request with swift header. | |
| static qint64 | lastModifiedMsSinceEpoch (const QNetworkReply *nwReply) |
| Last modified from reply. | |
| static QDateTime | lastModifiedDateTime (const QNetworkReply *nwReply) |
| Last modified from reply. | |
| static qint64 | lastModifiedSinceNow (const QNetworkReply *nwReply) |
| Last modified from reply compared with now (in ms). | |
| static qint64 | requestDuration (const QNetworkReply *nwReply) |
| Request duration (only works if requested by swift functions). | |
| static int | getHttpStatusCode (QNetworkReply *nwReply) |
| Get the http status code. | |
| static bool | isHttpStatusRedirect (QNetworkReply *nwReply) |
| Is the reply an HTTP redirect? | |
| static QUrl | getHttpRedirectUrl (QNetworkReply *nwReply) |
| Get the redirect URL if any. | |
| static QString | removeHtmlPartsFromPhpErrorMessage (const QString &errorMessage) |
| Remove the HTML formatting from a PHP error message. | |
| static bool | looksLikePhpErrorMessage (const QString &errorMessage) |
| Looks like PHP error messages. | |
| static const QString & | networkOperationToString (QNetworkAccessManager::Operation operation) |
| Operation to string. | |
Utilities, e.g. checking whether a network connection can be established.
Definition at line 28 of file networkutils.h.
Request type.
Definition at line 32 of file networkutils.h.
|
static |
Add debug flag.
Definition at line 180 of file networkutils.cpp.
|
static |
Build / concatenate an URL.
Definition at line 153 of file networkutils.cpp.
|
static |
Can connect?
| hostAddress | 130.4.20.3, or myserver.com |
| port | 80, 1234 |
| timeoutMs | |
| message | human readable message |
Definition at line 57 of file networkutils.cpp.
|
static |
Can connect to URL?
Definition at line 93 of file networkutils.cpp.
|
static |
Can connect to URL?
Definition at line 127 of file networkutils.cpp.
|
static |
Can connect to URL?
Definition at line 103 of file networkutils.cpp.
|
static |
Can connect to server?
| server | |
| message | human readable message |
| timeoutMs |
Definition at line 88 of file networkutils.cpp.
|
static |
Get the redirect URL if any.
Definition at line 271 of file networkutils.cpp.
|
static |
Get the http status code.
Definition at line 246 of file networkutils.cpp.
|
static |
Find out my IPv4 addresses including loopback, empty if not possible.
Definition at line 37 of file networkutils.cpp.
|
static |
Default for timeout (long).
Definition at line 35 of file networkutils.cpp.
|
static |
Get a copied network request with swift header.
Definition at line 197 of file networkutils.cpp.
|
static |
Our tweaked network request with swift header.
Definition at line 182 of file networkutils.cpp.
|
static |
Default for timeout.
Definition at line 33 of file networkutils.cpp.
|
static |
Is the reply an HTTP redirect?
Status codes:
Definition at line 261 of file networkutils.cpp.
|
static |
Valid IPv4 address.
Definition at line 133 of file networkutils.cpp.
|
static |
Valid IPv6 address.
Definition at line 139 of file networkutils.cpp.
|
static |
Valid port.
Definition at line 145 of file networkutils.cpp.
|
static |
Last modified from reply.
Definition at line 212 of file networkutils.cpp.
|
static |
Last modified from reply.
Definition at line 205 of file networkutils.cpp.
|
static |
Last modified from reply compared with now (in ms).
Definition at line 223 of file networkutils.cpp.
|
static |
Looks like PHP error messages.
Definition at line 301 of file networkutils.cpp.
|
static |
Operation to string.
Definition at line 310 of file networkutils.cpp.
|
static |
Remove the HTML formatting from a PHP error message.
Definition at line 290 of file networkutils.cpp.
|
static |
Request duration (only works if requested by swift functions).
Definition at line 230 of file networkutils.cpp.
|
static |
Set user agent for request.
Definition at line 170 of file networkutils.cpp.