Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhttpmultipart.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// Qt-Security score:significant reason:default
4
5#ifndef QHTTPMULTIPART_H
6#define QHTTPMULTIPART_H
7
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtCore/QSharedDataPointer>
10#include <QtCore/QByteArray>
11#include <QtCore/QIODevice>
12#include <QtNetwork/QNetworkRequest>
13
14#ifndef Q_OS_WASM
16#endif
17
18QT_BEGIN_NAMESPACE
19
20
21class QHttpPartPrivate;
22class QHttpMultiPart;
23class QDebug;
24
25class Q_NETWORK_EXPORT QHttpPart
26{
27public:
28 QHttpPart();
29 QHttpPart(const QHttpPart &other);
30 ~QHttpPart();
31 QHttpPart &operator=(QHttpPart &&other) noexcept { swap(other); return *this; }
32 QHttpPart &operator=(const QHttpPart &other);
33
34 void swap(QHttpPart &other) noexcept { d.swap(other.d); }
35
36 bool operator==(const QHttpPart &other) const;
37 inline bool operator!=(const QHttpPart &other) const
38 { return !operator==(other); }
39
40 void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
41 void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue);
42
43 void setBody(const QByteArray &body);
44 void setBodyDevice(QIODevice *device);
45
46private:
47 QSharedDataPointer<QHttpPartPrivate> d;
48
49 friend class QHttpMultiPartIODevice;
50#ifndef QT_NO_DEBUG_STREAM
51 friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QHttpPart &httpPart);
52#endif
53};
54
56
57class QHttpMultiPartPrivate;
58
59class Q_NETWORK_EXPORT QHttpMultiPart : public QObject
60{
61 Q_OBJECT
62
63public:
64
65 enum ContentType {
66 MixedType,
67 RelatedType,
68 FormDataType,
69 AlternativeType
70 };
71
72 explicit QHttpMultiPart(QObject *parent = nullptr);
73 explicit QHttpMultiPart(ContentType contentType, QObject *parent = nullptr);
74 ~QHttpMultiPart();
75
76 void append(const QHttpPart &httpPart);
77
78 void setContentType(ContentType contentType);
79
80 QByteArray boundary() const;
81 void setBoundary(const QByteArray &boundary);
82
83private:
84 Q_DECLARE_PRIVATE(QHttpMultiPart)
85 Q_DISABLE_COPY(QHttpMultiPart)
86
87 friend class QNetworkAccessManager;
88 friend class QNetworkAccessManagerPrivate;
89};
90
91QT_END_NAMESPACE
92
93#endif // QHTTPMULTIPART_H
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP.
The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message.
QT_REQUIRE_CONFIG(http)