|
swift
|
Utilities, e.g. checking whether a network connection can be established. More...
Public Types | |
| enum | RequestType { Get , PostUrlEncoded , Multipart } |
| Request type. | |
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? More... | |
| static bool | canConnect (const swift::misc::network::CServer &server, QString &message, int timeoutMs=getTimeoutMs()) |
| Can connect to server? More... | |
| 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? More... | |
| 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.
|
static |
Can connect?
| hostAddress | 130.4.20.3, or myserver.com |
| port | 80, 1234 |
| timeoutMs | |
| message | human readable message |
Definition at line 54 of file networkutils.cpp.
|
static |
Can connect to server?
| server | |
| message | human readable message |
| timeoutMs |
Definition at line 82 of file networkutils.cpp.
|
static |
Is the reply an HTTP redirect?
Status codes:
Definition at line 240 of file networkutils.cpp.