Add QHttpHeaders methods to QNetworkProxy
[ChangeLog][QtNetwork][QNetworkProxy] Added headers() and setHeaders() methods to QNetworkProxy to provide an interface to work with QHttpHeaders. Task-number: QTBUG-107751 Change-Id: I8a82f56f0262c9f44d0cb52b2e411bf75626b926 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
bbff35a343
commit
65fef44ddf
|
|
@ -751,6 +751,53 @@ QNetworkProxy QNetworkProxy::applicationProxy()
|
|||
return QNetworkProxy();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 6.8
|
||||
|
||||
Returns headers that are set in this network request.
|
||||
|
||||
If the proxy is not of type HttpProxy or HttpCachingProxy,
|
||||
default constructed QHttpHeaders is returned.
|
||||
|
||||
\sa setHeaders()
|
||||
*/
|
||||
QHttpHeaders QNetworkProxy::headers() const
|
||||
{
|
||||
if (d->type != HttpProxy && d->type != HttpCachingProxy)
|
||||
return {};
|
||||
return d->headers.headers();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 6.8
|
||||
|
||||
Sets \a newHeaders as headers in this network request, overriding
|
||||
any previously set headers.
|
||||
|
||||
If some headers correspond to the known headers, the values will
|
||||
be parsed and the corresponding parsed form will also be set.
|
||||
|
||||
If the proxy is not of type HttpProxy or HttpCachingProxy this has no
|
||||
effect.
|
||||
|
||||
\sa headers(), QNetworkRequest::KnownHeaders
|
||||
*/
|
||||
void QNetworkProxy::setHeaders(QHttpHeaders &&newHeaders)
|
||||
{
|
||||
if (d->type == HttpProxy || d->type == HttpCachingProxy)
|
||||
d->headers.setHeaders(std::move(newHeaders));
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.8
|
||||
*/
|
||||
void QNetworkProxy::setHeaders(const QHttpHeaders &newHeaders)
|
||||
{
|
||||
if (d->type == HttpProxy || d->type == HttpCachingProxy)
|
||||
d->headers.setHeaders(newHeaders);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.0
|
||||
Returns the value of the known network header \a header if it is
|
||||
|
|
|
|||
|
|
@ -136,6 +136,10 @@ public:
|
|||
static void setApplicationProxy(const QNetworkProxy &proxy);
|
||||
static QNetworkProxy applicationProxy();
|
||||
|
||||
QHttpHeaders headers() const;
|
||||
void setHeaders(const QHttpHeaders &newHeaders);
|
||||
void setHeaders(QHttpHeaders &&newHeaders);
|
||||
|
||||
// "cooked" headers
|
||||
QVariant header(QNetworkRequest::KnownHeaders header) const;
|
||||
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue