54 lines
913 B
C++
Executable File
54 lines
913 B
C++
Executable File
#pragma once
|
|
|
|
#include <httq/httq_export.h>
|
|
#include <httq/Logger.h>
|
|
|
|
#include <QObject>
|
|
#include <QScopedPointer>
|
|
|
|
|
|
class QIODevice;
|
|
|
|
|
|
namespace httq
|
|
{
|
|
class HttpRequest;
|
|
|
|
class HTTQ_EXPORT DataStream : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private:
|
|
explicit DataStream(QIODevice *from, QIODevice *to, const QByteArray &bodyPartial,
|
|
qint64 fileLength, size_t bufferSize, LoggerFactory *loggerFactory,
|
|
QObject *parent = nullptr);
|
|
|
|
public:
|
|
~DataStream();
|
|
|
|
private:
|
|
friend class HttpRequest;
|
|
|
|
void readNext();
|
|
void writeNext();
|
|
|
|
bool mReadyWrite { true };
|
|
|
|
QByteArray mBuffer;
|
|
QByteArray mBodyPartial;
|
|
QIODevice *mFrom;
|
|
QIODevice *mTo;
|
|
|
|
qint64 mBufferSize;
|
|
qint64 alreadyRead { 0 };
|
|
qint64 mFileLength;
|
|
bool mFromSupportsSignals { false };
|
|
bool mToSupportsSignals { false };
|
|
QScopedPointer<Logger> mLogger;
|
|
|
|
signals:
|
|
void signalDone();
|
|
|
|
};
|
|
}
|