QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCNetworkHelper Namespace Reference

Classes

struct  RequestConfig
 Common request configuration options. More...
 

Typedefs

using HttpStatusCode = QHttpServerResponder::StatusCode
 HTTP status codes - uses Qt's QHttpServerResponder::StatusCode enum.
 
using HttpMethod = QHttpServerRequest::Method
 HTTP request methods - uses Qt's QHttpServerRequest::Method enum.
 

Enumerations

enum class  HttpStatusClass {
  Informational , Success , Redirection , ClientError ,
  ServerError , Unknown
}
 HTTP status code ranges. More...
 
enum class  ConnectionType {
  None , Unknown , Ethernet , WiFi ,
  Cellular , Bluetooth
}
 Network connection types. More...
 

Functions

HttpStatusClass classifyHttpStatus (int statusCode)
 Classify an HTTP status code.
 
QString httpStatusText (HttpStatusCode statusCode)
 
QString httpStatusText (int statusCode)
 Get human-readable description for HTTP status code.
 
QString httpMethodName (HttpMethod method)
 Get string name for an HTTP method (e.g., "GET", "POST")
 
HttpMethod parseHttpMethod (const QString &methodStr)
 
bool isValidUrl (const QUrl &url)
 
bool isHttpUrl (const QUrl &url)
 Check if URL uses HTTP or HTTPS scheme.
 
bool isHttpsUrl (const QUrl &url)
 Check if URL uses secure HTTPS scheme.
 
QUrl normalizeUrl (const QUrl &url)
 Normalize URL (lowercase scheme/host, remove default ports, trailing slashes)
 
QUrl ensureScheme (const QUrl &url, const QString &defaultScheme=QStringLiteral("https"))
 Ensure URL has scheme, defaulting to https:// if missing.
 
QUrl buildUrl (const QString &baseUrl, const QMap< QString, QString > &params)
 Build URL with query parameters from a map.
 
QUrl buildUrl (const QString &baseUrl, const QList< QPair< QString, QString > > &params)
 Build URL with query parameters from a list of pairs.
 
QString urlFileName (const QUrl &url)
 Extract filename from URL path (last path segment)
 
QUrl urlWithoutQuery (const QUrl &url)
 Get URL without query string and fragment.
 
void configureRequest (QNetworkRequest &request, const RequestConfig &config)
 
QNetworkRequest createRequest (const QUrl &url, const RequestConfig &config)
 
void setStandardHeaders (QNetworkRequest &request, const QString &userAgent={})
 Set standard browser-like headers on a request.
 
void setJsonHeaders (QNetworkRequest &request)
 Set JSON content headers (Accept and Content-Type)
 
void setFormHeaders (QNetworkRequest &request)
 Set form data content headers.
 
QString defaultUserAgent ()
 Get the default User-Agent string for QGC.
 
void setBasicAuth (QNetworkRequest &request, const QString &credentials)
 
void setBasicAuth (QNetworkRequest &request, const QString &username, const QString &password)
 
void setBearerToken (QNetworkRequest &request, const QString &token)
 
QString createBasicAuthCredentials (const QString &username, const QString &password)
 
QHttpPart createFormField (const QString &name, const QString &value)
 
QHttpPart createFilePart (const QString &name, const QString &fileName, const QString &contentType, QIODevice *device)
 
QHttpPart createFilePart (const QString &name, const QString &fileName, QIODevice *device)
 
QSslConfiguration createSslConfig (QSsl::SslProtocol protocol)
 
QSslConfiguration createInsecureSslConfig ()
 
void applySslConfig (QNetworkRequest &request, const QSslConfiguration &config)
 
QJsonDocument parseJson (const QByteArray &data, QJsonParseError *error)
 
QJsonDocument parseJsonReply (QNetworkReply *reply, QJsonParseError *error)
 
bool looksLikeJson (const QByteArray &data)
 
int httpStatusCode (const QNetworkReply *reply)
 
QUrl redirectUrl (const QNetworkReply *reply)
 
QString errorMessage (const QNetworkReply *reply)
 
bool isSuccess (const QNetworkReply *reply)
 Check if reply indicates success (no error and HTTP 2xx)
 
bool isRedirect (const QNetworkReply *reply)
 Check if reply indicates a redirect.
 
QString contentType (const QNetworkReply *reply)
 Get Content-Type header from reply.
 
qint64 contentLength (const QNetworkReply *reply)
 Get Content-Length header from reply (-1 if not present)
 
bool isJsonResponse (const QNetworkReply *reply)
 Check if response is JSON based on Content-Type.
 
bool isNetworkAvailable ()
 Check if network is available (not disconnected)
 
bool isInternetAvailable ()
 Check if internet is reachable (online state, stricter than isNetworkAvailable)
 
bool isNetworkEthernet ()
 Check if current network connection is Ethernet.
 
bool isBluetoothAvailable ()
 Check if Bluetooth is available on this device.
 
ConnectionType connectionType ()
 Get current network connection type.
 
QString connectionTypeName (ConnectionType type)
 Get human-readable name for connection type.
 
void ignoreSslErrors (QNetworkReply *reply)
 
void ignoreSslErrorsIfNeeded (QNetworkReply *reply)
 
bool isSslAvailable ()
 Check if SSL is available.
 
QString sslVersion ()
 Get SSL library version string.
 
void initializeProxySupport ()
 
QNetworkAccessManager * createNetworkManager (QObject *parent)
 
void configureProxy (QNetworkAccessManager *manager)
 Set up default proxy configuration on a network manager.
 
bool looksLikeCompressedData (const QByteArray &data)
 
QJsonDocument parseCompressedJson (const QByteArray &data, QJsonParseError *error)
 
bool isHttpSuccess (int statusCode)
 Check if HTTP status indicates success (2xx)
 
bool isHttpRedirect (int statusCode)
 Check if HTTP status indicates redirect (3xx)
 
bool isHttpClientError (int statusCode)
 Check if HTTP status indicates client error (4xx)
 
bool isHttpServerError (int statusCode)
 Check if HTTP status indicates server error (5xx)
 

Variables

constexpr int kDefaultTimeoutMs = 30000
 Default request timeout in milliseconds.
 
constexpr int kDefaultConnectTimeoutMs = 10000
 Default connection timeout for initial connect.
 
constexpr int kMaxRedirects = 10
 Maximum number of redirects to follow.
 
const QString kContentTypeJson = QStringLiteral("application/json")
 Common MIME types for Content-Type headers.
 
const QString kContentTypeFormUrlencoded = QStringLiteral("application/x-www-form-urlencoded")
 
const QString kContentTypeOctetStream = QStringLiteral("application/octet-stream")
 
const QString kContentTypeMultipartForm = QStringLiteral("multipart/form-data")
 
const QString kContentTypeXml = QStringLiteral("application/xml")
 
const QString kContentTypeTextPlain = QStringLiteral("text/plain")
 

Detailed Description

Network utility functions for HTTP requests, URL handling, and connectivity All functions are stateless and thread-safe

Typedef Documentation

◆ HttpMethod

using QGCNetworkHelper::HttpMethod = typedef QHttpServerRequest::Method

HTTP request methods - uses Qt's QHttpServerRequest::Method enum.

Definition at line 102 of file QGCNetworkHelper.h.

◆ HttpStatusCode

using QGCNetworkHelper::HttpStatusCode = typedef QHttpServerResponder::StatusCode

HTTP status codes - uses Qt's QHttpServerResponder::StatusCode enum.

Definition at line 53 of file QGCNetworkHelper.h.

Enumeration Type Documentation

◆ ConnectionType

Network connection types.

Enumerator
None 

No network connection.

Unknown 

Connection type unknown.

Ethernet 

Wired ethernet.

WiFi 

Wireless LAN.

Cellular 

Mobile/cellular data.

Bluetooth 

Bluetooth connection.

Definition at line 322 of file QGCNetworkHelper.h.

◆ HttpStatusClass

HTTP status code ranges.

Enumerator
Informational 

1xx - Informational

Success 

2xx - Success

Redirection 

3xx - Redirection

ClientError 

4xx - Client errors

ServerError 

5xx - Server errors

Unknown 

Not a valid HTTP status.

Definition at line 56 of file QGCNetworkHelper.h.

Function Documentation

◆ applySslConfig()

void QGCNetworkHelper::applySslConfig ( QNetworkRequest &  request,
const QSslConfiguration &  config 
)

Apply SSL configuration to a request

Parameters
requestRequest to modify
configSSL configuration to apply

Definition at line 532 of file QGCNetworkHelper.cc.

References applySslConfig().

Referenced by applySslConfig().

◆ buildUrl() [1/2]

QUrl QGCNetworkHelper::buildUrl ( const QString &  baseUrl,
const QList< QPair< QString, QString > > &  params 
)

Build URL with query parameters from a list of pairs.

Definition at line 335 of file QGCNetworkHelper.cc.

References buildUrl().

◆ buildUrl() [2/2]

QUrl QGCNetworkHelper::buildUrl ( const QString &  baseUrl,
const QMap< QString, QString > &  params 
)

Build URL with query parameters from a map.

Definition at line 319 of file QGCNetworkHelper.cc.

References buildUrl().

Referenced by buildUrl(), and buildUrl().

◆ classifyHttpStatus()

HttpStatusClass QGCNetworkHelper::classifyHttpStatus ( int  statusCode)

Classify an HTTP status code.

Definition at line 27 of file QGCNetworkHelper.cc.

References classifyHttpStatus().

Referenced by classifyHttpStatus(), and httpStatusText().

◆ configureProxy()

void QGCNetworkHelper::configureProxy ( QNetworkAccessManager *  manager)

Set up default proxy configuration on a network manager.

Definition at line 868 of file QGCNetworkHelper.cc.

References configureProxy().

Referenced by configureProxy(), createNetworkManager(), TerrainOnlineQuery::TerrainOnlineQuery(), and TerrainTileManager::TerrainTileManager().

◆ configureRequest()

◆ connectionType()

ConnectionType QGCNetworkHelper::connectionType ( )

Get current network connection type.

Definition at line 758 of file QGCNetworkHelper.cc.

References connectionType().

Referenced by connectionType().

◆ connectionTypeName()

QString QGCNetworkHelper::connectionTypeName ( ConnectionType  type)

Get human-readable name for connection type.

Definition at line 787 of file QGCNetworkHelper.cc.

References connectionTypeName().

Referenced by connectionTypeName().

◆ contentLength()

qint64 QGCNetworkHelper::contentLength ( const QNetworkReply *  reply)

Get Content-Length header from reply (-1 if not present)

Definition at line 677 of file QGCNetworkHelper.cc.

References contentLength().

Referenced by contentLength().

◆ contentType()

QString QGCNetworkHelper::contentType ( const QNetworkReply *  reply)

Get Content-Type header from reply.

Definition at line 669 of file QGCNetworkHelper.cc.

References contentType().

Referenced by contentType(), createFilePart(), and isJsonResponse().

◆ createBasicAuthCredentials()

QString QGCNetworkHelper::createBasicAuthCredentials ( const QString &  username,
const QString &  password 
)

Create Basic Auth credentials string from username and password

Returns
Base64-encoded "username:password" string

Definition at line 481 of file QGCNetworkHelper.cc.

References createBasicAuthCredentials().

Referenced by createBasicAuthCredentials(), and setBasicAuth().

◆ createFilePart() [1/2]

QHttpPart QGCNetworkHelper::createFilePart ( const QString &  name,
const QString &  fileName,
const QString &  contentType,
QIODevice *  device 
)

Create a file upload part

Parameters
nameField name (e.g., "filearg")
fileNameDisplay filename
contentTypeMIME type of the file (e.g., "application/octet-stream")
deviceIO device to read file data from (must stay valid during upload)
Returns
QHttpPart configured as file upload

Definition at line 499 of file QGCNetworkHelper.cc.

References contentType(), and createFilePart().

Referenced by createFilePart(), and createFilePart().

◆ createFilePart() [2/2]

QHttpPart QGCNetworkHelper::createFilePart ( const QString &  name,
const QString &  fileName,
QIODevice *  device 
)

Create a file upload part with auto-detected content type

Parameters
nameField name
fileNameDisplay filename (used for content-type detection)
deviceIO device to read file data from
Returns
QHttpPart configured as file upload

Definition at line 509 of file QGCNetworkHelper.cc.

References createFilePart(), and kContentTypeOctetStream.

◆ createFormField()

QHttpPart QGCNetworkHelper::createFormField ( const QString &  name,
const QString &  value 
)

Create a simple text form field part

Parameters
nameField name
valueField value
Returns
QHttpPart configured as form-data

Definition at line 491 of file QGCNetworkHelper.cc.

References createFormField().

Referenced by createFormField().

◆ createInsecureSslConfig()

QSslConfiguration QGCNetworkHelper::createInsecureSslConfig ( )

Create SSL configuration that disables peer verification (use with caution!) Only for development/testing or known self-signed certificates

Returns
QSslConfiguration with peer verification disabled

Definition at line 525 of file QGCNetworkHelper.cc.

References createInsecureSslConfig().

Referenced by createInsecureSslConfig().

◆ createNetworkManager()

QNetworkAccessManager * QGCNetworkHelper::createNetworkManager ( QObject *  parent = nullptr)

Create a network access manager with recommended settings Caller takes ownership of the returned pointer

Definition at line 861 of file QGCNetworkHelper.cc.

References configureProxy(), and createNetworkManager().

Referenced by createNetworkManager().

◆ createRequest()

QNetworkRequest QGCNetworkHelper::createRequest ( const QUrl &  url,
const RequestConfig config = {} 
)

Create a pre-configured QNetworkRequest

Parameters
urlThe URL for the request
configConfiguration options (uses defaults if not specified)
Returns
Configured QNetworkRequest ready for use

Definition at line 423 of file QGCNetworkHelper.cc.

References configureRequest(), and createRequest().

Referenced by createRequest(), and QGCFileDownload::start().

◆ createSslConfig()

QSslConfiguration QGCNetworkHelper::createSslConfig ( QSsl::SslProtocol  protocol = QSsl::TlsV1_2OrLater)

Create SSL configuration with specified protocol

Parameters
protocolTLS protocol version (default: TLS 1.2 or later)
Returns
Configured QSslConfiguration

Definition at line 518 of file QGCNetworkHelper.cc.

References createSslConfig().

Referenced by createSslConfig().

◆ defaultUserAgent()

QString QGCNetworkHelper::defaultUserAgent ( )

Get the default User-Agent string for QGC.

Definition at line 450 of file QGCNetworkHelper.cc.

References defaultUserAgent().

Referenced by configureRequest(), defaultUserAgent(), and setStandardHeaders().

◆ ensureScheme()

QUrl QGCNetworkHelper::ensureScheme ( const QUrl &  url,
const QString &  defaultScheme 
)

Ensure URL has scheme, defaulting to https:// if missing.

Definition at line 304 of file QGCNetworkHelper.cc.

References ensureScheme().

Referenced by ensureScheme().

◆ errorMessage()

QString QGCNetworkHelper::errorMessage ( const QNetworkReply *  reply)

Get error message from a network reply Combines network error and HTTP status into readable message

Definition at line 625 of file QGCNetworkHelper.cc.

References errorMessage(), httpStatusCode(), and httpStatusText().

Referenced by errorMessage().

◆ httpMethodName()

QString QGCNetworkHelper::httpMethodName ( HttpMethod  method)

Get string name for an HTTP method (e.g., "GET", "POST")

Definition at line 195 of file QGCNetworkHelper.cc.

References httpMethodName().

Referenced by httpMethodName().

◆ httpStatusCode()

int QGCNetworkHelper::httpStatusCode ( const QNetworkReply *  reply)

Get HTTP status code from a network reply Returns -1 if not an HTTP response

Definition at line 601 of file QGCNetworkHelper.cc.

References httpStatusCode().

Referenced by errorMessage(), httpStatusCode(), isRedirect(), and isSuccess().

◆ httpStatusText() [1/2]

QString QGCNetworkHelper::httpStatusText ( HttpStatusCode  statusCode)

Definition at line 47 of file QGCNetworkHelper.cc.

References httpStatusText().

Referenced by errorMessage(), httpStatusText(), and httpStatusText().

◆ httpStatusText() [2/2]

QString QGCNetworkHelper::httpStatusText ( int  statusCode)

Get human-readable description for HTTP status code.

Definition at line 182 of file QGCNetworkHelper.cc.

References classifyHttpStatus(), and httpStatusText().

◆ ignoreSslErrors()

void QGCNetworkHelper::ignoreSslErrors ( QNetworkReply *  reply)

Configure SSL to ignore certificate errors (use with caution!) This should only be used for development/testing or known self-signed certs

Definition at line 810 of file QGCNetworkHelper.cc.

References error, and ignoreSslErrors().

Referenced by ignoreSslErrors().

◆ ignoreSslErrorsIfNeeded()

void QGCNetworkHelper::ignoreSslErrorsIfNeeded ( QNetworkReply *  reply)

Ignore SSL errors if there's an OpenSSL version mismatch Qt may be built with OpenSSL 1.x but running with OpenSSL 3.x, causing certificate issues

Definition at line 825 of file QGCNetworkHelper.cc.

References ignoreSslErrorsIfNeeded().

Referenced by ignoreSslErrorsIfNeeded(), and QGCFileDownload::start().

◆ initializeProxySupport()

void QGCNetworkHelper::initializeProxySupport ( )

Initialize network proxy support (call once at application startup) Enables system proxy configuration for all network requests

Definition at line 856 of file QGCNetworkHelper.cc.

References initializeProxySupport().

Referenced by initializeProxySupport(), and QGCApplication::QGCApplication().

◆ isBluetoothAvailable()

bool QGCNetworkHelper::isBluetoothAvailable ( )

Check if Bluetooth is available on this device.

Definition at line 752 of file QGCNetworkHelper.cc.

References isBluetoothAvailable().

Referenced by isBluetoothAvailable().

◆ isHttpClientError()

bool QGCNetworkHelper::isHttpClientError ( int  statusCode)
inline

Check if HTTP status indicates client error (4xx)

Definition at line 82 of file QGCNetworkHelper.h.

◆ isHttpRedirect()

bool QGCNetworkHelper::isHttpRedirect ( int  statusCode)
inline

Check if HTTP status indicates redirect (3xx)

Definition at line 76 of file QGCNetworkHelper.h.

Referenced by isRedirect().

◆ isHttpServerError()

bool QGCNetworkHelper::isHttpServerError ( int  statusCode)
inline

Check if HTTP status indicates server error (5xx)

Definition at line 88 of file QGCNetworkHelper.h.

◆ isHttpSuccess()

bool QGCNetworkHelper::isHttpSuccess ( int  statusCode)
inline

Check if HTTP status indicates success (2xx)

Definition at line 70 of file QGCNetworkHelper.h.

Referenced by isSuccess().

◆ isHttpsUrl()

bool QGCNetworkHelper::isHttpsUrl ( const QUrl &  url)

Check if URL uses secure HTTPS scheme.

Definition at line 269 of file QGCNetworkHelper.cc.

References isHttpsUrl().

Referenced by isHttpsUrl().

◆ isHttpUrl()

bool QGCNetworkHelper::isHttpUrl ( const QUrl &  url)

Check if URL uses HTTP or HTTPS scheme.

Definition at line 263 of file QGCNetworkHelper.cc.

References isHttpUrl().

Referenced by isHttpUrl().

◆ isInternetAvailable()

bool QGCNetworkHelper::isInternetAvailable ( )

Check if internet is reachable (online state, stricter than isNetworkAvailable)

Definition at line 712 of file QGCNetworkHelper.cc.

References isInternetAvailable().

Referenced by isInternetAvailable(), and QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC().

◆ isJsonResponse()

bool QGCNetworkHelper::isJsonResponse ( const QNetworkReply *  reply)

Check if response is JSON based on Content-Type.

Definition at line 686 of file QGCNetworkHelper.cc.

References contentType(), and isJsonResponse().

Referenced by isJsonResponse().

◆ isNetworkAvailable()

bool QGCNetworkHelper::isNetworkAvailable ( )

Check if network is available (not disconnected)

Definition at line 697 of file QGCNetworkHelper.cc.

References isNetworkAvailable().

Referenced by isNetworkAvailable().

◆ isNetworkEthernet()

bool QGCNetworkHelper::isNetworkEthernet ( )

Check if current network connection is Ethernet.

Definition at line 734 of file QGCNetworkHelper.cc.

References isNetworkEthernet().

Referenced by isNetworkEthernet(), TCPLink::isSecureConnection(), and UDPLink::isSecureConnection().

◆ isRedirect()

bool QGCNetworkHelper::isRedirect ( const QNetworkReply *  reply)

Check if reply indicates a redirect.

Definition at line 659 of file QGCNetworkHelper.cc.

References httpStatusCode(), isHttpRedirect(), isRedirect(), and redirectUrl().

Referenced by isRedirect().

◆ isSslAvailable()

bool QGCNetworkHelper::isSslAvailable ( )

Check if SSL is available.

Definition at line 842 of file QGCNetworkHelper.cc.

References isSslAvailable().

Referenced by isSslAvailable().

◆ isSuccess()

bool QGCNetworkHelper::isSuccess ( const QNetworkReply *  reply)

Check if reply indicates success (no error and HTTP 2xx)

Definition at line 645 of file QGCNetworkHelper.cc.

References httpStatusCode(), isHttpSuccess(), and isSuccess().

Referenced by isSuccess().

◆ isValidUrl()

bool QGCNetworkHelper::isValidUrl ( const QUrl &  url)

Check if URL is valid and has supported scheme Supported: http, https, file, qrc

Definition at line 252 of file QGCNetworkHelper.cc.

References isValidUrl().

Referenced by isValidUrl().

◆ looksLikeCompressedData()

bool QGCNetworkHelper::looksLikeCompressedData ( const QByteArray &  data)

Check if data appears to be compressed based on magic bytes Detects: gzip, xz, zstd, bzip2, lz4

Parameters
dataData to check (needs at least 4 bytes)
Returns
true if data has a recognized compression magic signature

Definition at line 885 of file QGCNetworkHelper.cc.

References QGCCompression::detectFormatFromData(), QGCCompression::isCompressionFormat(), and looksLikeCompressedData().

Referenced by looksLikeCompressedData(), and parseCompressedJson().

◆ looksLikeJson()

bool QGCNetworkHelper::looksLikeJson ( const QByteArray &  data)

Check if data appears to be valid JSON (quick check)

Parameters
dataData to check
Returns
true if data starts with { or [

Definition at line 579 of file QGCNetworkHelper.cc.

References looksLikeJson().

Referenced by looksLikeJson().

◆ normalizeUrl()

QUrl QGCNetworkHelper::normalizeUrl ( const QUrl &  url)

Normalize URL (lowercase scheme/host, remove default ports, trailing slashes)

Definition at line 274 of file QGCNetworkHelper.cc.

References normalizeUrl().

Referenced by normalizeUrl().

◆ parseCompressedJson()

QJsonDocument QGCNetworkHelper::parseCompressedJson ( const QByteArray &  data,
QJsonParseError *  error = nullptr 
)

Parse JSON that may be compressed Automatically detects and decompresses gzip, xz, zstd, bzip2, lz4 data

Parameters
dataRaw data (compressed or uncompressed JSON)
errorOptional pointer to receive parse error details
Returns
Parsed JSON document (null if parsing failed)

Definition at line 890 of file QGCNetworkHelper.cc.

References QGCCompression::decompressData(), error, looksLikeCompressedData(), and parseCompressedJson().

Referenced by TerrainTileCopernicus::getJsonFromData(), JsonParsing::isJsonFile(), JsonHelper::openInternalQGCJsonFile(), and parseCompressedJson().

◆ parseHttpMethod()

HttpMethod QGCNetworkHelper::parseHttpMethod ( const QString &  methodStr)

Parse HTTP method from string (case-insensitive) Returns HttpMethod::Get if not recognized

Definition at line 221 of file QGCNetworkHelper.cc.

References parseHttpMethod().

Referenced by parseHttpMethod().

◆ parseJson()

QJsonDocument QGCNetworkHelper::parseJson ( const QByteArray &  data,
QJsonParseError *  error = nullptr 
)

Parse JSON from network reply data

Parameters
dataRaw response data
errorOptional pointer to receive parse error details
Returns
Parsed JSON document (null if parsing failed)

Definition at line 541 of file QGCNetworkHelper.cc.

References error, and parseJson().

Referenced by parseJson(), and parseJsonReply().

◆ parseJsonReply()

QJsonDocument QGCNetworkHelper::parseJsonReply ( QNetworkReply *  reply,
QJsonParseError *  error = nullptr 
)

Parse JSON from network reply

Parameters
replyNetwork reply to read from
errorOptional pointer to receive parse error details
Returns
Parsed JSON document (null if parsing failed or reply has error)

Definition at line 557 of file QGCNetworkHelper.cc.

References error, parseJson(), and parseJsonReply().

Referenced by parseJsonReply().

◆ redirectUrl()

QUrl QGCNetworkHelper::redirectUrl ( const QNetworkReply *  reply)

Get redirect URL from a reply, if any Returns empty URL if no redirect

Definition at line 610 of file QGCNetworkHelper.cc.

References redirectUrl().

Referenced by isRedirect(), and redirectUrl().

◆ setBasicAuth() [1/2]

void QGCNetworkHelper::setBasicAuth ( QNetworkRequest &  request,
const QString &  credentials 
)

Set HTTP Basic Authentication header

Parameters
requestRequest to modify
credentialsBase64-encoded "username:password" string

Definition at line 466 of file QGCNetworkHelper.cc.

References setBasicAuth().

Referenced by setBasicAuth(), and setBasicAuth().

◆ setBasicAuth() [2/2]

void QGCNetworkHelper::setBasicAuth ( QNetworkRequest &  request,
const QString &  username,
const QString &  password 
)

Set HTTP Basic Authentication header from username and password

Parameters
requestRequest to modify
usernameThe username
passwordThe password

Definition at line 471 of file QGCNetworkHelper.cc.

References createBasicAuthCredentials(), and setBasicAuth().

◆ setBearerToken()

void QGCNetworkHelper::setBearerToken ( QNetworkRequest &  request,
const QString &  token 
)

Set Bearer token authentication header

Parameters
requestRequest to modify
tokenThe bearer token (without "Bearer " prefix)

Definition at line 476 of file QGCNetworkHelper.cc.

References setBearerToken().

Referenced by setBearerToken().

◆ setFormHeaders()

void QGCNetworkHelper::setFormHeaders ( QNetworkRequest &  request)

Set form data content headers.

Definition at line 445 of file QGCNetworkHelper.cc.

References setFormHeaders().

Referenced by setFormHeaders().

◆ setJsonHeaders()

void QGCNetworkHelper::setJsonHeaders ( QNetworkRequest &  request)

Set JSON content headers (Accept and Content-Type)

Definition at line 439 of file QGCNetworkHelper.cc.

References setJsonHeaders().

Referenced by setJsonHeaders().

◆ setStandardHeaders()

void QGCNetworkHelper::setStandardHeaders ( QNetworkRequest &  request,
const QString &  userAgent 
)

Set standard browser-like headers on a request.

Definition at line 430 of file QGCNetworkHelper.cc.

References defaultUserAgent(), and setStandardHeaders().

Referenced by setStandardHeaders().

◆ sslVersion()

QString QGCNetworkHelper::sslVersion ( )

Get SSL library version string.

Definition at line 847 of file QGCNetworkHelper.cc.

References sslVersion().

Referenced by sslVersion().

◆ urlFileName()

QString QGCNetworkHelper::urlFileName ( const QUrl &  url)

Extract filename from URL path (last path segment)

Definition at line 351 of file QGCNetworkHelper.cc.

References urlFileName().

Referenced by urlFileName().

◆ urlWithoutQuery()

QUrl QGCNetworkHelper::urlWithoutQuery ( const QUrl &  url)

Get URL without query string and fragment.

Definition at line 361 of file QGCNetworkHelper.cc.

References urlWithoutQuery().

Referenced by urlWithoutQuery().

Variable Documentation

◆ kContentTypeFormUrlencoded

const QString QGCNetworkHelper::kContentTypeFormUrlencoded = QStringLiteral("application/x-www-form-urlencoded")
inline

Definition at line 42 of file QGCNetworkHelper.h.

◆ kContentTypeJson

const QString QGCNetworkHelper::kContentTypeJson = QStringLiteral("application/json")
inline

Common MIME types for Content-Type headers.

Definition at line 41 of file QGCNetworkHelper.h.

◆ kContentTypeMultipartForm

const QString QGCNetworkHelper::kContentTypeMultipartForm = QStringLiteral("multipart/form-data")
inline

Definition at line 44 of file QGCNetworkHelper.h.

◆ kContentTypeOctetStream

const QString QGCNetworkHelper::kContentTypeOctetStream = QStringLiteral("application/octet-stream")
inline

Definition at line 43 of file QGCNetworkHelper.h.

Referenced by createFilePart().

◆ kContentTypeTextPlain

const QString QGCNetworkHelper::kContentTypeTextPlain = QStringLiteral("text/plain")
inline

Definition at line 46 of file QGCNetworkHelper.h.

◆ kContentTypeXml

const QString QGCNetworkHelper::kContentTypeXml = QStringLiteral("application/xml")
inline

Definition at line 45 of file QGCNetworkHelper.h.

◆ kDefaultConnectTimeoutMs

constexpr int QGCNetworkHelper::kDefaultConnectTimeoutMs = 10000
constexpr

Default connection timeout for initial connect.

Definition at line 31 of file QGCNetworkHelper.h.

◆ kDefaultTimeoutMs

constexpr int QGCNetworkHelper::kDefaultTimeoutMs = 30000
constexpr

Default request timeout in milliseconds.

Definition at line 28 of file QGCNetworkHelper.h.

◆ kMaxRedirects

constexpr int QGCNetworkHelper::kMaxRedirects = 10
constexpr

Maximum number of redirects to follow.

Definition at line 34 of file QGCNetworkHelper.h.