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 QNETWORKACCESSFILEBACKEND_P_H
5#define QNETWORKACCESSFILEBACKEND_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 "QtCore/qfile.h"
23
24QT_BEGIN_NAMESPACE
25
26class QNetworkAccessFileBackend: public QNetworkAccessBackend
27{
28 Q_OBJECT
29public:
30 QNetworkAccessFileBackend();
31 virtual ~QNetworkAccessFileBackend();
32
33 void open() override;
34 void close() override;
35
36 qint64 bytesAvailable() const override;
37 qint64 read(char *data, qint64 maxlen) override;
38
39public slots:
40 void uploadReadyReadSlot();
41private:
42 QFile file;
43 qint64 totalBytes;
44 bool hasUploadFinished;
45
46 bool loadFileInfo();
47};
48
49class QNetworkAccessFileBackendFactory: public QNetworkAccessBackendFactory
50{
51public:
52 virtual QStringList supportedSchemes() const override;
53 virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
54 const QNetworkRequest &request) const override;
55};
56
57QT_END_NAMESPACE
58
59#endif
60

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