42 #include "QtCore/qdatetime.h"
43 #include "QtCore/qmutex.h"
44 #include "QtCore/qrandom.h"
300 d_func()->parts.append(httpPart);
327 return d_func()->boundary;
355 checkHeaderCreated();
368 checkHeaderCreated();
373 if (readPointer < headerDataCount) {
374 bytesRead = qMin(headerDataCount - readPointer, maxSize);
375 const char *headerData = header.
constData();
376 memcpy(
data, headerData + readPointer, bytesRead);
377 readPointer += bytesRead;
380 if (bytesRead < maxSize) {
383 if (dataBytesRead == -1)
385 bytesRead += dataBytesRead;
386 readPointer += dataBytesRead;
388 qint64 contentBytesRead = qMin(
body.
count() - readPointer + headerDataCount, maxSize - bytesRead);
392 memcpy(
data + bytesRead, contentData + readPointer - headerDataCount, contentBytesRead);
393 bytesRead += contentBytesRead;
394 readPointer += contentBytesRead;
402 checkHeaderCreated();
421 void QHttpPartPrivate::checkHeaderCreated()
const
423 if (!headerCreated) {
428 header +=
it->first +
": " +
it->second +
"\r\n";
430 headerCreated =
true;
459 currentSize += boundaryCount + 6;
504 if (partIndex < boundaryCount) {
505 qint64 boundaryBytesRead = qMin(boundaryCount - partIndex, maxSize - bytesRead);
506 memcpy(
data + bytesRead, boundaryData.
constData() + partIndex, boundaryBytesRead);
507 bytesRead += boundaryBytesRead;
509 partIndex += boundaryBytesRead;
513 if (bytesRead < maxSize && partIndex >= boundaryCount && partIndex < boundaryCount + multiPart->parts.at(
index).d->size()) {
515 if (dataBytesRead == -1)
517 bytesRead += dataBytesRead;
519 partIndex += dataBytesRead;
524 if (bytesRead == maxSize - 1)
526 memcpy(
data + bytesRead,
"\r\n", 2);
533 if (bytesRead < maxSize && index == multiPart->parts.count()) {
536 qint64 lastBoundaryBytesRead = qMin(finalBoundary.
count() - boundaryIndex, maxSize - bytesRead);
537 memcpy(
data + bytesRead, finalBoundary.
constData() + boundaryIndex, lastBoundaryBytesRead);
538 bytesRead += lastBoundaryBytesRead;
The QByteArray class provides an array of bytes.
const char * constData() const noexcept
QByteArray toBase64(Base64Options options=Base64Encoding) const
qsizetype count(char c) const
static QByteArray fromRawData(const char *data, qsizetype size)
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP.
void append(const QHttpPart &httpPart)
QByteArray boundary() const
void setContentType(ContentType contentType)
void setBoundary(const QByteArray &boundary)
QHttpMultiPart(QObject *parent=nullptr)
virtual bool isSequential() const override
virtual qint64 size() const override
virtual bool reset() override
QList< qint64 > partOffsets
virtual qint64 readData(char *data, qint64 maxSize) override
virtual qint64 writeData(const char *data, qint64 maxSize) override
QHttpMultiPartPrivate * multiPart
The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message.
bool operator==(const QHttpPart &other) const
void setBodyDevice(QIODevice *device)
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
void setBody(const QByteArray &body)
QHttpPart & operator=(QHttpPart &&other) noexcept
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
void setBody(const QByteArray &newBody)
qint64 readData(char *data, qint64 maxSize)
qint64 bytesAvailable() const
void setBodyDevice(QIODevice *device)
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual qint64 size() const
virtual qint64 bytesAvailable() const
qint64 read(char *data, qint64 maxlen)
const_reference at(qsizetype i) const noexcept
const_iterator constBegin() const noexcept
qsizetype count() const noexcept
void append(parameter_type t)
const_iterator constEnd() const noexcept
The QObject class is the base class of all Qt objects.
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
void fillRange(UInt *buffer, qsizetype count)
The QVariant class acts like a union for the most common Qt data types.
std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, GeneratorWrapper< T > >::type random(T a, T b)
typename C::const_iterator const_iterator
EGLOutputLayerEXT EGLint EGLAttrib value
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"))
[1]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent