Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
22#include "private/qobject_p.h"
23
24#ifndef Q_OS_WASM
26#endif
27
29
30
32{
33public:
34 inline QHttpPartPrivate() : bodyDevice(nullptr), headerCreated(false), readPointer(0)
35 {
36 }
38 {
39 }
40
41
44 header(other.header), headerCreated(other.headerCreated), readPointer(other.readPointer)
45 {
46 bodyDevice = other.bodyDevice;
47 }
48
49 inline bool operator==(const QHttpPartPrivate &other) const
50 {
52 && body == other.body
53 && bodyDevice == other.bodyDevice
54 && readPointer == other.readPointer;
55 }
56
59 readPointer = 0;
60 }
61 void setBody(const QByteArray &newBody) {
62 body = newBody;
63 readPointer = 0;
64 }
65
66 // QIODevice-style methods called by QHttpMultiPartIODevice (but this class is
67 // not a QIODevice):
68 qint64 bytesAvailable() const;
69 qint64 readData(char *data, qint64 maxSize);
70 qint64 size() const;
71 bool reset();
72
75
76private:
77 void checkHeaderCreated() const;
78
79 mutable QByteArray header;
80 mutable bool headerCreated;
81 qint64 readPointer;
82};
83
84
85
87
89{
90public:
92 QIODevice(), multiPart(parentMultiPart), readPointer(0), deviceSize(-1) {
93 }
94
97
98 virtual bool atEnd() const override {
99 return readPointer == size();
100 }
101
102 virtual qint64 bytesAvailable() const override {
103 return size() - readPointer;
104 }
105
106 virtual void close() override {
107 readPointer = 0;
108 partOffsets.clear();
109 deviceSize = -1;
111 }
112
113 virtual qint64 bytesToWrite() const override {
114 return 0;
115 }
116
117 virtual qint64 size() const override;
118 virtual bool isSequential() const override;
119 virtual bool reset() override;
120 virtual qint64 readData(char *data, qint64 maxSize) override;
121 virtual qint64 writeData(const char *data, qint64 maxSize) override;
122
125 mutable QList<qint64> partOffsets;
127};
128
129
130
148
150
151
152#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.
\inmodule QtCore
Definition qshareddata.h:19
Q_NETWORK_EXPORT bool compareStrict(const QHttpHeaders &left, const QHttpHeaders &right)
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:60
QObject::connect nullptr
QByteArray readData()
QSharedPointer< T > other(t)
[5]
QHttpMultiPart * multiPart
[0]