diff options
Diffstat (limited to 'src/network/access/qhttpnetworkrequest.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkrequest.cpp | 72 |
1 files changed, 24 insertions, 48 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index e3c699efed..7a4ffb1684 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -1,47 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qhttpnetworkrequest_p.h" #include "private/qnoncontiguousbytedevice_p.h" QT_BEGIN_NAMESPACE +QT_IMPL_METATYPE_EXTERN(QHttpNetworkRequest) + QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, QHttpNetworkRequest::Priority pri, const QUrl &newUrl) : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(nullptr), @@ -61,6 +27,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest pipeliningAllowed(other.pipeliningAllowed), http2Allowed(other.http2Allowed), http2Direct(other.http2Direct), + h2cAllowed(other.h2cAllowed), withCredentials(other.withCredentials), ssl(other.ssl), preConnect(other.preConnect), @@ -85,6 +52,7 @@ bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &ot && (pipeliningAllowed == other.pipeliningAllowed) && (http2Allowed == other.http2Allowed) && (http2Direct == other.http2Direct) + && (h2cAllowed == other.h2cAllowed) // we do not clear the customVerb in setOperation && (operation != QHttpNetworkRequest::Custom || (customVerb == other.customVerb)) && (withCredentials == other.withCredentials) @@ -144,9 +112,9 @@ QByteArray QHttpNetworkRequest::uri(bool throughProxy) const QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy) { - QList<QPair<QByteArray, QByteArray> > fields = request.header(); + const QHttpHeaders headers = request.header(); QByteArray ba; - ba.reserve(40 + fields.length()*25); // very rough lower bound estimation + ba.reserve(40 + headers.size() * 25); // very rough lower bound estimation ba += request.methodName(); ba += ' '; @@ -158,12 +126,10 @@ QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request ba += QByteArray::number(request.minorVersion()); ba += "\r\n"; - QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin(); - QList<QPair<QByteArray, QByteArray> >::const_iterator endIt = fields.constEnd(); - for (; it != endIt; ++it) { - ba += it->first; + for (qsizetype i = 0; i < headers.size(); ++i) { + ba += headers.nameAt(i); ba += ": "; - ba += it->second; + ba += headers.valueAt(i); ba += "\r\n"; } if (request.d->operation == QHttpNetworkRequest::Post) { @@ -269,12 +235,12 @@ void QHttpNetworkRequest::setContentLength(qint64 length) d->setContentLength(length); } -QList<QPair<QByteArray, QByteArray> > QHttpNetworkRequest::header() const +QHttpHeaders QHttpNetworkRequest::header() const { - return d->fields; + return d->parser.headers(); } -QByteArray QHttpNetworkRequest::headerField(const QByteArray &name, const QByteArray &defaultValue) const +QByteArray QHttpNetworkRequest::headerField(QByteArrayView name, const QByteArray &defaultValue) const { return d->headerField(name, defaultValue); } @@ -365,6 +331,16 @@ void QHttpNetworkRequest::setHTTP2Direct(bool b) d->http2Direct = b; } +bool QHttpNetworkRequest::isH2cAllowed() const +{ + return d->h2cAllowed; +} + +void QHttpNetworkRequest::setH2cAllowed(bool b) +{ + d->h2cAllowed = b; +} + bool QHttpNetworkRequest::withCredentials() const { return d->withCredentials; |