Don't send the default SETTINGS_INITIAL_WINDOW_SIZE

And don't set non-default large value in QNetworkRequest's constructor.
Some servers consider those values as 'flow control error'.

Pick-to: 6.2
Fixes: QTBUG-97384
Change-Id: I801b7c83fe7e7392a02ba653c36dfa8a22c21d1e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Timur Pocheptsov 2021-10-11 14:30:29 +02:00
parent b836098179
commit 0e58b3db34
3 changed files with 14 additions and 13 deletions

View File

@ -71,9 +71,12 @@ Frame configurationToSettingsFrame(const QHttp2Configuration &config)
// Server push:
builder.append(Settings::ENABLE_PUSH_ID);
builder.append(int(config.serverPushEnabled()));
// Stream receive window size:
builder.append(Settings::INITIAL_WINDOW_SIZE_ID);
builder.append(config.streamReceiveWindowSize());
// Stream receive window size (if it's a default value, don't include):
if (config.streamReceiveWindowSize() != defaultSessionWindowSize) {
builder.append(Settings::INITIAL_WINDOW_SIZE_ID);
builder.append(config.streamReceiveWindowSize());
}
if (config.maxFrameSize() != minPayloadLimit) {
builder.append(Settings::MAX_FRAME_SIZE_ID);

View File

@ -98,9 +98,6 @@ class QHttp2ConfigurationPrivate : public QSharedData
{
public:
unsigned sessionWindowSize = Http2::defaultSessionWindowSize;
// The size below is quite a limiting default value, QNetworkRequest
// by default sets a larger number, an application can change this using
// QNetworkRequest::setHttp2Configuration.
unsigned streamWindowSize = Http2::defaultSessionWindowSize;
unsigned maxFrameSize = Http2::minPayloadLimit; // Initial (default) value of 16Kb.
@ -256,7 +253,7 @@ bool QHttp2Configuration::setStreamReceiveWindowSize(unsigned size)
/*!
Returns the window size for stream-level flow control.
The default value QNetworkAccessManager will be using is
21474836 octets.
65535 octets (see \l {https://httpwg.org/specs/rfc7540.html#SettingValues}{RFC 7540}).
*/
unsigned QHttp2Configuration::streamReceiveWindowSize() const
{

View File

@ -492,13 +492,14 @@ public:
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);
// Initial values proposed by RFC 7540 are quite draconian, but we
// know about servers configured with this value as maximum possible,
// rejecting our SETTINGS frame and sending us a GOAWAY frame with the
// flow control error set. Unless an application sets its own parameters,
// we don't send SETTINGS_INITIAL_WINDOW_SIZE, but increase
// (via WINDOW_UPDATE) the session window size. These are our 'defaults':
d->h2Configuration.setStreamReceiveWindowSize(Http2::defaultSessionWindowSize);
d->h2Configuration.setSessionReceiveWindowSize(Http2::maxSessionReceiveWindowSize);
d->h2Configuration.setServerPushEnabled(false);
#endif // QT_CONFIG(http)