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

source code of qtbase/src/network/access/qnetworkaccessdebugpipebackend_p.h