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 <QtNetwork/qhttpmultipart.h>
20
21#include "QtCore/qshareddata.h"
22#include "qnetworkrequest_p.h" // for deriving QHttpPartPrivate from QNetworkHeadersPrivate
24
25#include "private/qobject_p.h"
26#include <QtCore/qiodevice.h>
27
28#ifndef Q_OS_WASM
30#endif
31
33
34
36{
37public:
38 inline QHttpPartPrivate() : bodyDevice(nullptr), headerCreated(false), readPointer(0)
39 {
40 }
42 {
43 }
44
45
48 header(other.header), headerCreated(other.headerCreated), readPointer(other.readPointer)
49 {
50 bodyDevice = other.bodyDevice;
51 }
52
53 inline bool operator==(const QHttpPartPrivate &other) const
54 {
56 && body == other.body
57 && bodyDevice == other.bodyDevice
58 && readPointer == other.readPointer;
59 }
60
63 readPointer = 0;
64 }
65 void setBody(const QByteArray &newBody) {
66 body = newBody;
67 readPointer = 0;
68 }
69
70 // QIODevice-style methods called by QHttpMultiPartIODevice (but this class is
71 // not a QIODevice):
72 qint64 bytesAvailable() const;
73 qint64 readData(char *data, qint64 maxSize);
74 qint64 size() const;
75 bool reset();
76
79
80private:
81 void checkHeaderCreated() const;
82
83 mutable QByteArray header;
84 mutable bool headerCreated;
85 qint64 readPointer;
86};
87
88
89
91
93{
94public:
96 QIODevice(), multiPart(parentMultiPart), readPointer(0), deviceSize(-1) {
97 }
98
100
101 virtual bool atEnd() const override {
102 return readPointer == size();
103 }
104
105 virtual qint64 bytesAvailable() const override {
106 return size() - readPointer;
107 }
108
109 virtual void close() override {
110 readPointer = 0;
111 partOffsets.clear();
112 deviceSize = -1;
114 }
115
116 virtual qint64 bytesToWrite() const override {
117 return 0;
118 }
119
120 virtual qint64 size() const override;
121 virtual bool isSequential() const override;
122 virtual bool reset() override;
123 virtual qint64 readData(char *data, qint64 maxSize) override;
124 virtual qint64 writeData(const char *data, qint64 maxSize) override;
125
128 mutable QList<qint64> partOffsets;
130};
131
132
133
153
155
156
157#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.
~QHttpMultiPartIODevice() override
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....
static const QHttpMultiPartPrivate * get(const QHttpMultiPart *message)
QHttpMultiPart::ContentType contentType
QList< QHttpPart > parts
static QHttpMultiPartPrivate * get(QHttpMultiPart *message)
QHttpMultiPartIODevice * device
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP.
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
GLuint GLsizei const GLchar * message
#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]