| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | // Qt-Security score:significant reason:default |
| 4 | |
| 5 | #ifndef QNETWORKACCESSDEBUGPIPEBACKEND_P_H |
| 6 | #define QNETWORKACCESSDEBUGPIPEBACKEND_P_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists for the convenience |
| 13 | // of the Network Access API. This header file may change from |
| 14 | // version to version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
| 20 | #include "qnetworkaccessbackend_p.h" |
| 21 | #include "qnetworkrequest.h" |
| 22 | #include "qnetworkreply.h" |
| 23 | #include "qtcpsocket.h" |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | #ifdef QT_BUILD_INTERNAL |
| 28 | |
| 29 | class QNetworkAccessDebugPipeBackend: public QNetworkAccessBackend |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | public: |
| 33 | QNetworkAccessDebugPipeBackend(); |
| 34 | virtual ~QNetworkAccessDebugPipeBackend(); |
| 35 | |
| 36 | void open() override; |
| 37 | void close() override; |
| 38 | |
| 39 | qint64 read(char *data, qint64 maxlen) override; |
| 40 | qint64 bytesAvailable() const override; |
| 41 | |
| 42 | protected: |
| 43 | void pushFromUpstreamToSocket(); |
| 44 | void possiblyFinish(); |
| 45 | |
| 46 | private slots: |
| 47 | void uploadReadyReadSlot(); |
| 48 | void socketReadyRead(); |
| 49 | void socketBytesWritten(qint64 bytes); |
| 50 | void socketError(); |
| 51 | void socketDisconnected(); |
| 52 | void socketConnected(); |
| 53 | |
| 54 | private: |
| 55 | QTcpSocket socket; |
| 56 | bool bareProtocol; |
| 57 | bool hasUploadFinished; |
| 58 | bool hasDownloadFinished; |
| 59 | bool hasEverythingFinished; |
| 60 | |
| 61 | qint64 bytesDownloaded; |
| 62 | qint64 bytesUploaded; |
| 63 | }; |
| 64 | |
| 65 | class QNetworkAccessDebugPipeBackendFactory: public QNetworkAccessBackendFactory |
| 66 | { |
| 67 | public: |
| 68 | virtual QStringList supportedSchemes() const override; |
| 69 | virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op, |
| 70 | const QNetworkRequest &request) const override; |
| 71 | }; |
| 72 | |
| 73 | #endif // QT_BUILD_INTERNAL |
| 74 | |
| 75 | QT_END_NAMESPACE |
| 76 | |
| 77 | #endif |
| 78 |
