6#include "QtCore/qdatetime.h"
7#include "QtCore/qmutex.h"
8#include "QtCore/qrandom.h"
249 d->contentType = contentType;
264 d_func()->parts.append(httpPart);
281 d_func()->contentType = contentType;
291 return d_func()->boundary;
319 checkHeaderCreated();
332 checkHeaderCreated();
337 if (readPointer < headerDataCount) {
338 bytesRead =
qMin(headerDataCount - readPointer, maxSize);
339 const char *headerData = header.
constData();
340 memcpy(
data, headerData + readPointer, bytesRead);
341 readPointer += bytesRead;
344 if (bytesRead < maxSize) {
347 if (dataBytesRead == -1)
349 bytesRead += dataBytesRead;
350 readPointer += dataBytesRead;
352 qint64 contentBytesRead =
qMin(
body.
size() - readPointer + headerDataCount, maxSize - bytesRead);
356 memcpy(
data + bytesRead, contentData + readPointer - headerDataCount, contentBytesRead);
357 bytesRead += contentBytesRead;
358 readPointer += contentBytesRead;
366 checkHeaderCreated();
385void QHttpPartPrivate::checkHeaderCreated()
const
387 if (!headerCreated) {
392 header +=
it->first +
": " +
it->second +
"\r\n";
394 headerCreated =
true;
423 currentSize += boundaryCount + 6;
456 while (index < multiPart->parts.size() &&
462 while (bytesRead < maxSize && index < multiPart->parts.size()) {
468 if (partIndex < boundaryCount) {
469 qint64 boundaryBytesRead =
qMin(boundaryCount - partIndex, maxSize - bytesRead);
470 memcpy(
data + bytesRead, boundaryData.
constData() + partIndex, boundaryBytesRead);
471 bytesRead += boundaryBytesRead;
473 partIndex += boundaryBytesRead;
477 if (bytesRead < maxSize && partIndex >= boundaryCount && partIndex < boundaryCount + multiPart->parts.at(
index).d->size()) {
479 if (dataBytesRead == -1)
481 bytesRead += dataBytesRead;
483 partIndex += dataBytesRead;
488 if (bytesRead == maxSize - 1)
490 memcpy(
data + bytesRead,
"\r\n", 2);
497 if (bytesRead < maxSize && index == multiPart->parts.size()) {
500 qint64 lastBoundaryBytesRead =
qMin(finalBoundary.
size() - boundaryIndex, maxSize - bytesRead);
501 memcpy(
data + bytesRead, finalBoundary.
constData() + boundaryIndex, lastBoundaryBytesRead);
502 bytesRead += lastBoundaryBytesRead;
518#include "moc_qhttpmultipart.cpp"
IOBluetoothDevice * device
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray toBase64(Base64Options options=Base64Encoding) const
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
virtual bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
virtual qint64 size() const override
For open random-access devices, this function returns the size of the device.
virtual bool reset() override
Seeks to the start of input for random-access devices.
QList< qint64 > partOffsets
virtual qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
virtual qint64 writeData(const char *data, qint64 maxSize) override
Writes up to maxSize bytes from data to the device.
QHttpMultiPartPrivate * multiPart
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP.
~QHttpMultiPart()
Destroys the multipart.
ContentType
List of known content types for a multipart subtype as described in RFC 2046 and others.
void append(const QHttpPart &httpPart)
Appends httpPart to this multipart.
QByteArray boundary() const
returns the boundary.
void setContentType(ContentType contentType)
Sets the content type to contentType.
void setBoundary(const QByteArray &boundary)
Sets the boundary to boundary.
QHttpMultiPart(QObject *parent=nullptr)
Constructs a QHttpMultiPart with content type MixedType and sets parent as the parent object.
void setBody(const QByteArray &newBody)
qint64 readData(char *data, qint64 maxSize)
qint64 bytesAvailable() const
void setBodyDevice(QIODevice *device)
The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message.
bool operator==(const QHttpPart &other) const
Returns true if this object is the same as other (i.e., if they have the same headers and body).
QHttpPart & operator=(QHttpPart &&other) noexcept
void setBodyDevice(QIODevice *device)
Sets the device to read the content from to device.
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
Sets the value of the known header header to be value, overriding any previously set headers.
QHttpPart()
Constructs an empty QHttpPart object.
void setBody(const QByteArray &body)
Sets the body of this MIME part to body.
~QHttpPart()
Destroys this QHttpPart.
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
Sets the header headerName to be of value headerValue.
\inmodule QtCore \reentrant
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual bool reset()
Seeks to the start of input for random-access devices.
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
const_iterator constBegin() const noexcept
void append(parameter_type t)
const_iterator constEnd() const noexcept
KnownHeaders
List of known header types that QNetworkRequest parses.
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
void fillRange(UInt *buffer, qsizetype count)
Generates count 32- or 64-bit quantities (depending on the type UInt) and stores them in the buffer p...
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value)
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent