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)
 
QList< QSslCertificate > loadCaCertificates (const QString &filePath, QString *errorOut)
 
bool loadClientCertAndKey (const QString &certPath, const QString &keyPath, QSslCertificate &certOut, QSslKey &keyOut, QString *errorOut)
 
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 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 104 of file QGCNetworkHelper.h.

◆ HttpStatusCode

using QGCNetworkHelper::HttpStatusCode = typedef QHttpServerResponder::StatusCode

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

Definition at line 55 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 342 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 58 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 533 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 336 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 320 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 28 of file QGCNetworkHelper.cc.

References classifyHttpStatus().

Referenced by classifyHttpStatus(), and httpStatusText().

◆ configureProxy()

void QGCNetworkHelper::configureProxy ( QNetworkAccessManager *  manager)

◆ configureRequest()

◆ connectionType()

ConnectionType QGCNetworkHelper::connectionType ( )

Get current network connection type.

Definition at line 799 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 828 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 718 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 710 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 482 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 500 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 510 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 492 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 526 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 902 of file QGCNetworkHelper.cc.

References configureProxy(), and createNetworkManager().

Referenced by createNetworkManager(), and NTRIPSourceTableFetcher::NTRIPSourceTableFetcher().

◆ 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 424 of file QGCNetworkHelper.cc.

References configureRequest(), and createRequest().

Referenced by createRequest(), NTRIPSourceTableFetcher::fetch(), 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 519 of file QGCNetworkHelper.cc.

References createSslConfig().

Referenced by createSslConfig().

◆ defaultUserAgent()

QString QGCNetworkHelper::defaultUserAgent ( )

Get the default User-Agent string for QGC.

Definition at line 451 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 305 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 666 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 196 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 642 of file QGCNetworkHelper.cc.

References httpStatusCode().

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

◆ httpStatusText() [1/2]

QString QGCNetworkHelper::httpStatusText ( HttpStatusCode  statusCode)

Definition at line 48 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 183 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 851 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 866 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 897 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 793 of file QGCNetworkHelper.cc.

References isBluetoothAvailable().

Referenced by BluetoothConfiguration::isBluetoothAvailable(), LinkManager::isBluetoothAvailable(), and isBluetoothAvailable().

◆ isHttpClientError()

bool QGCNetworkHelper::isHttpClientError ( int  statusCode)
inline

Check if HTTP status indicates client error (4xx)

Definition at line 84 of file QGCNetworkHelper.h.

◆ isHttpRedirect()

bool QGCNetworkHelper::isHttpRedirect ( int  statusCode)
inline

Check if HTTP status indicates redirect (3xx)

Definition at line 78 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 90 of file QGCNetworkHelper.h.

◆ isHttpSuccess()

bool QGCNetworkHelper::isHttpSuccess ( int  statusCode)
inline

Check if HTTP status indicates success (2xx)

Definition at line 72 of file QGCNetworkHelper.h.

Referenced by isSuccess().

◆ isHttpsUrl()

bool QGCNetworkHelper::isHttpsUrl ( const QUrl &  url)

Check if URL uses secure HTTPS scheme.

Definition at line 270 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 264 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 753 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 727 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 738 of file QGCNetworkHelper.cc.

References isNetworkAvailable().

Referenced by isNetworkAvailable().

◆ isNetworkEthernet()

bool QGCNetworkHelper::isNetworkEthernet ( )

Check if current network connection is Ethernet.

Definition at line 775 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 700 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 883 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 686 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 253 of file QGCNetworkHelper.cc.

References isValidUrl().

Referenced by isValidUrl().

◆ loadCaCertificates()

QList< QSslCertificate > QGCNetworkHelper::loadCaCertificates ( const QString &  filePath,
QString *  errorOut = nullptr 
)

Load CA certificates from a PEM file

Parameters
filePathPath to PEM file containing one or more certificates
errorOutOptional pointer to receive error message
Returns
List of certificates (empty on failure)

Definition at line 538 of file QGCNetworkHelper.cc.

References loadCaCertificates().

Referenced by loadCaCertificates(), and LogRemoteSink::loadTlsCaCertificates().

◆ loadClientCertAndKey()

bool QGCNetworkHelper::loadClientCertAndKey ( const QString &  certPath,
const QString &  keyPath,
QSslCertificate &  certOut,
QSslKey &  keyOut,
QString *  errorOut = nullptr 
)

Load a client certificate and private key from PEM files Tries RSA first, then EC for the key format

Parameters
certPathPath to PEM file containing the client certificate
keyPathPath to PEM file containing the private key
certOutReceives the loaded certificate
keyOutReceives the loaded key
errorOutOptional pointer to receive error message
Returns
true on success

Definition at line 547 of file QGCNetworkHelper.cc.

References loadClientCertAndKey().

Referenced by loadClientCertAndKey(), and LogRemoteSink::loadTlsClientCertificate().

◆ 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 620 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 275 of file QGCNetworkHelper.cc.

References normalizeUrl().

Referenced by normalizeUrl().

◆ parseHttpMethod()

HttpMethod QGCNetworkHelper::parseHttpMethod ( const QString &  methodStr)

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

Definition at line 222 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 582 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 598 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 651 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 467 of file QGCNetworkHelper.cc.

References setBasicAuth().

Referenced by NTRIPSourceTableFetcher::fetch(), 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 472 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 477 of file QGCNetworkHelper.cc.

References setBearerToken().

Referenced by setBearerToken().

◆ setFormHeaders()

void QGCNetworkHelper::setFormHeaders ( QNetworkRequest &  request)

Set form data content headers.

Definition at line 446 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 440 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 431 of file QGCNetworkHelper.cc.

References defaultUserAgent(), and setStandardHeaders().

Referenced by setStandardHeaders().

◆ sslVersion()

QString QGCNetworkHelper::sslVersion ( )

Get SSL library version string.

Definition at line 888 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 352 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 362 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 44 of file QGCNetworkHelper.h.

◆ kContentTypeJson

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

Common MIME types for Content-Type headers.

Definition at line 43 of file QGCNetworkHelper.h.

◆ kContentTypeMultipartForm

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

Definition at line 46 of file QGCNetworkHelper.h.

◆ kContentTypeOctetStream

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

Definition at line 45 of file QGCNetworkHelper.h.

Referenced by createFilePart().

◆ kContentTypeTextPlain

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

Definition at line 48 of file QGCNetworkHelper.h.

◆ kContentTypeXml

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

Definition at line 47 of file QGCNetworkHelper.h.

◆ kDefaultConnectTimeoutMs

constexpr int QGCNetworkHelper::kDefaultConnectTimeoutMs = 10000
constexpr

Default connection timeout for initial connect.

Definition at line 33 of file QGCNetworkHelper.h.

◆ kDefaultTimeoutMs

constexpr int QGCNetworkHelper::kDefaultTimeoutMs = 30000
constexpr

Default request timeout in milliseconds.

Definition at line 30 of file QGCNetworkHelper.h.

◆ kMaxRedirects

constexpr int QGCNetworkHelper::kMaxRedirects = 10
constexpr

Maximum number of redirects to follow.

Definition at line 36 of file QGCNetworkHelper.h.