Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qhttpmultipart_p.h
Go to the documentation of this file.
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 QHTTPMULTIPART_P_H
5#define QHTTPMULTIPART_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 "QtCore/qshareddata.h"
20#include "qnetworkrequest_p.h" // for deriving QHttpPartPrivate from QNetworkHeadersPrivate
21#include "private/qobject_p.h"
22
23#ifndef Q_OS_WASM
25#endif
26
28
29
31{
32public:
33 inline QHttpPartPrivate() : bodyDevice(nullptr), headerCreated(false), readPointer(0)
34 {
35 }
37 {
38 }
39
40
43 header(other.header), headerCreated(other.headerCreated), readPointer(other.readPointer)
44 {
45 bodyDevice = other.bodyDevice;
46 }
47
48 inline bool operator==(const QHttpPartPrivate &other) const
49 {
50 return rawHeaders == other.rawHeaders && body == other.body &&
51 bodyDevice == other.bodyDevice && readPointer == other.readPointer;
52 }
53
56 readPointer = 0;
57 }
58 void setBody(const QByteArray &newBody) {
59 body = newBody;
60 readPointer = 0;
61 }
62
63 // QIODevice-style methods called by QHttpMultiPartIODevice (but this class is
64 // not a QIODevice):
65 qint64 bytesAvailable() const;
66 qint64 readData(char *data, qint64 maxSize);
67 qint64 size() const;
68 bool reset();
69
72
73private:
74 void checkHeaderCreated() const;
75
76 mutable QByteArray header;
77 mutable bool headerCreated;
78 qint64 readPointer;
79};
80
81
82
84
86{
87public:
89 QIODevice(), multiPart(parentMultiPart), readPointer(0), deviceSize(-1) {
90 }
91
93 }
94
95 virtual bool atEnd() const override {
96 return readPointer == size();
97 }
98
99 virtual qint64 bytesAvailable() const override {
100 return size() - readPointer;
101 }
102
103 virtual void close() override {
104 readPointer = 0;
105 partOffsets.clear();
106 deviceSize = -1;
108 }
109
110 virtual qint64 bytesToWrite() const override {
111 return 0;
112 }
113
114 virtual qint64 size() const override;
115 virtual bool isSequential() const override;
116 virtual bool reset() override;
117 virtual qint64 readData(char *data, qint64 maxSize) override;
118 virtual qint64 writeData(const char *data, qint64 maxSize) override;
119
124};
125
126
127
129{
130public:
131
133
135 {
136 delete device;
137 }
138
143
144};
145
147
148
149#endif // QHTTPMULTIPART_P_H
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
virtual qint64 bytesToWrite() const override
For buffered devices, this function returns the number of bytes waiting to be written.
virtual void close() override
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
QHttpMultiPartIODevice(QHttpMultiPartPrivate *parentMultiPart)
QList< qint64 > partOffsets
QHttpMultiPartPrivate * multiPart
virtual bool atEnd() const override
Returns true if the current read and write position is at the end of the device (i....
QHttpMultiPart::ContentType contentType
QList< QHttpPart > parts
QHttpMultiPartIODevice * device
ContentType
List of known content types for a multipart subtype as described in RFC 2046 and others.
QHttpPartPrivate(const QHttpPartPrivate &other)
void setBody(const QByteArray &newBody)
bool operator==(const QHttpPartPrivate &other) const
QIODevice * bodyDevice
qint64 bytesAvailable() const
void setBodyDevice(QIODevice *device)
qint64 size() const
\inmodule QtCore \reentrant
Definition qiodevice.h:34
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool reset()
Seeks to the start of input for random-access devices.
Definition qlist.h:74
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
long long qint64
Definition qtypes.h:55
QObject::connect nullptr
QByteArray readData()
QSharedPointer< T > other(t)
[5]
QHttpMultiPart * multiPart
[0]