diff options
Diffstat (limited to 'src/network/access/qhttpnetworkreply_p.h')
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 83 |
1 files changed, 26 insertions, 57 deletions
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 618de43b14..caec82bd7e 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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 #ifndef QHTTPNETWORKREPLY_H #define QHTTPNETWORKREPLY_H @@ -77,6 +41,9 @@ Q_MOC_INCLUDE(<QtNetwork/QNetworkProxy>) Q_MOC_INCLUDE(<QtNetwork/QAuthenticator>) #include <private/qdecompresshelper_p.h> +#include <QtNetwork/qhttpheaders.h> + +#include <QtCore/qpointer.h> QT_REQUIRE_CONFIG(http); @@ -87,7 +54,7 @@ class QHttpNetworkConnectionChannel; class QHttpNetworkRequest; class QHttpNetworkConnectionPrivate; class QHttpNetworkReplyPrivate; -class Q_AUTOTEST_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader +class Q_NETWORK_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader { Q_OBJECT public: @@ -100,14 +67,17 @@ public: int majorVersion() const override; int minorVersion() const override; + void setMajorVersion(int version); + void setMinorVersion(int version); qint64 contentLength() const override; void setContentLength(qint64 length) override; - QList<QPair<QByteArray, QByteArray> > header() const override; - QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const override; + QHttpHeaders header() const override; + QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const override; void setHeaderField(const QByteArray &name, const QByteArray &data) override; - void parseHeader(const QByteArray &header); // mainly for testing + void appendHeaderField(const QByteArray &name, const QByteArray &data); + void parseHeader(QByteArrayView header); // used for testing QHttpNetworkRequest request() const; void setRequest(const QHttpNetworkRequest &request); @@ -121,6 +91,7 @@ public: QNetworkReply::NetworkError errorCode() const; QString reasonPhrase() const; + void setReasonPhrase(const QString &reason); qint64 bytesAvailable() const; qint64 bytesAvailableNextBlock() const; @@ -170,6 +141,8 @@ Q_SIGNALS: #endif Q_SIGNALS: + void socketStartedConnecting(); + void requestSent(); void readyRead(); void finished(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); @@ -199,20 +172,20 @@ class Q_AUTOTEST_EXPORT QHttpNetworkReplyPrivate : public QObjectPrivate, public public: QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl()); ~QHttpNetworkReplyPrivate(); - qint64 readStatus(QAbstractSocket *socket); - bool parseStatus(const QByteArray &status); - qint64 readHeader(QAbstractSocket *socket); - void parseHeader(const QByteArray &header); - qint64 readBody(QAbstractSocket *socket, QByteDataBuffer *out); - qint64 readBodyVeryFast(QAbstractSocket *socket, char *b); - qint64 readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb); - bool findChallenge(bool forProxy, QByteArray &challenge) const; + qint64 readStatus(QIODevice *socket); + bool parseStatus(QByteArrayView status); + qint64 readHeader(QIODevice *socket); + void parseHeader(QByteArrayView header); + void appendHeaderField(const QByteArray &name, const QByteArray &data); + qint64 readBody(QIODevice *socket, QByteDataBuffer *out); + qint64 readBodyVeryFast(QIODevice *socket, char *b); + qint64 readBodyFast(QIODevice *socket, QByteDataBuffer *rb); void clear(); void clearHttpLayerInformation(); - qint64 readReplyBodyRaw(QAbstractSocket *in, QByteDataBuffer *out, qint64 size); - qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out); - qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize); + qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size); + qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out); + qint64 getChunkSize(QIODevice *in, qint64 *chunkSize); bool isRedirecting() const; bool shouldEmitSignals(); @@ -241,11 +214,7 @@ public: QHttpNetworkRequest request; bool ssl; - int statusCode; - int majorVersion; - int minorVersion; QString errorString; - QString reasonPhrase; qint64 bodyLength; qint64 contentRead; qint64 totalProgress; |