summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkrequest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qnetworkrequest.cpp')
-rw-r--r--src/network/access/qnetworkrequest.cpp92
1 files changed, 89 insertions, 3 deletions
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index f15c43cdd8..118fb6b1fb 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -42,6 +42,10 @@
#include "qplatformdefs.h"
#include "qnetworkcookie.h"
#include "qsslconfiguration.h"
+#if QT_CONFIG(http) || defined(Q_CLANG_QDOC)
+#include "qhttp2configuration.h"
+#include "private/http2protocol_p.h"
+#endif
#include "QtCore/qshareddata.h"
#include "QtCore/qlocale.h"
#include "QtCore/qdatetime.h"
@@ -331,6 +335,12 @@ QT_BEGIN_NAMESPACE
\omitvalue ResourceTypeAttribute
+ \value AutoDeleteReplyOnFinishAttribute
+ Requests only, type: QMetaType::Bool (default: false)
+ If set, this attribute will make QNetworkAccessManager delete
+ the QNetworkReply after having emitted "finished".
+ (This value was introduced in 5.14.)
+
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
@@ -439,6 +449,9 @@ public:
sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
#endif
peerVerifyName = other.peerVerifyName;
+#if QT_CONFIG(http)
+ h2Configuration = other.h2Configuration;
+#endif
}
inline bool operator==(const QNetworkRequestPrivate &other) const
@@ -448,7 +461,11 @@ public:
rawHeaders == other.rawHeaders &&
attributes == other.attributes &&
maxRedirectsAllowed == other.maxRedirectsAllowed &&
- peerVerifyName == other.peerVerifyName;
+ peerVerifyName == other.peerVerifyName
+#if QT_CONFIG(http)
+ && h2Configuration == other.h2Configuration
+#endif
+ ;
// don't compare cookedHeaders
}
@@ -459,16 +476,39 @@ public:
#endif
int maxRedirectsAllowed;
QString peerVerifyName;
+#if QT_CONFIG(http)
+ QHttp2Configuration h2Configuration;
+#endif
};
/*!
+ Constructs a QNetworkRequest object with no URL to be requested.
+ Use setUrl() to set one.
+
+ \sa url(), setUrl()
+*/
+QNetworkRequest::QNetworkRequest()
+ : d(new QNetworkRequestPrivate)
+{
+#if QT_CONFIG(http)
+ // Initial values proposed by RFC 7540 are quite draconian,
+ // so unless an application will set its own parameters, we
+ // make stream window size larger and increase (via WINDOW_UPDATE)
+ // the session window size. These are our 'defaults':
+ d->h2Configuration.setStreamReceiveWindowSize(Http2::qtDefaultStreamReceiveWindowSize);
+ d->h2Configuration.setSessionReceiveWindowSize(Http2::maxSessionReceiveWindowSize);
+ d->h2Configuration.setServerPushEnabled(false);
+#endif // QT_CONFIG(http)
+}
+
+/*!
Constructs a QNetworkRequest object with \a url as the URL to be
requested.
\sa url(), setUrl()
*/
QNetworkRequest::QNetworkRequest(const QUrl &url)
- : d(new QNetworkRequestPrivate)
+ : QNetworkRequest()
{
d->url = url;
}
@@ -818,6 +858,52 @@ void QNetworkRequest::setPeerVerifyName(const QString &peerName)
d->peerVerifyName = peerName;
}
+#if QT_CONFIG(http) || defined(Q_CLANG_QDOC)
+/*!
+ \since 5.14
+
+ Returns the current parameters that QNetworkAccessManager is
+ using for this request and its underlying HTTP/2 connection.
+ This is either a configuration previously set by an application
+ or a default configuration.
+
+ The default values that QNetworkAccessManager is using are:
+
+ \list
+ \li Window size for connection-level flowcontrol is 2147483647 octets
+ \li Window size for stream-level flowcontrol is 21474836 octets
+ \li Max frame size is 16384
+ \endlist
+
+ By default, server push is disabled, Huffman compression and
+ string indexing are enabled.
+
+ \sa setHttp2Configuration
+*/
+QHttp2Configuration QNetworkRequest::http2Configuration() const
+{
+ return d->h2Configuration;
+}
+
+/*!
+ \since 5.14
+
+ Sets request's HTTP/2 parameters from \a configuration.
+
+ \note The configuration must be set prior to making a request.
+ \note HTTP/2 multiplexes several streams in a single HTTP/2
+ connection. This implies that QNetworkAccessManager will use
+ the configuration found in the first request from a series
+ of requests sent to the same host.
+
+ \sa http2Configuration, QNetworkAccessManager, QHttp2Configuration
+*/
+void QNetworkRequest::setHttp2Configuration(const QHttp2Configuration &configuration)
+{
+ d->h2Configuration = configuration;
+}
+#endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC)
+
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
{
switch (header) {
@@ -1338,7 +1424,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
QByteArray QNetworkHeadersPrivate::toHttpDate(const QDateTime &dt)
{
- return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'"))
+ return QLocale::c().toString(dt, u"ddd, dd MMM yyyy hh:mm:ss 'GMT'")
.toLatin1();
}