5#include <private/qhttpprotocolhandler_p.h>
6#include <private/qnoncontiguousbytedevice_p.h>
7#include <private/qhttpnetworkconnectionchannel_p.h>
8#include <private/qsocketabstraction_p.h>
25 qWarning() <<
"QAbstractProtocolHandler::_q_receiveReply() called without QHttpNetworkReply,"
34 if (!qobject_cast<QHttpNetworkConnection*>(
m_connection)) {
69 if (statusBytes == -1) {
81 if (headerBytes == -1) {
89 if (replyPrivate->isCompressed() && replyPrivate->autoDecompress) {
91 replyPrivate->removeAutoDecompressHeader();
93 replyPrivate->autoDecompress =
false;
96 if (statusCode == 100 || (102 <= statusCode && statusCode <= 199)) {
97 replyPrivate->clearHttpLayerInformation();
101 if (replyPrivate->shouldEmitSignals())
107 if (!replyPrivate->expectContent()) {
118 replyPrivate->downstreamLimited && !replyPrivate->responseData.isEmpty() && replyPrivate->shouldEmitSignals()) {
129 if (replyPrivate->userProvidedDownloadBuffer) {
134 qint64 haveRead = replyPrivate->readBodyVeryFast(
m_socket, replyPrivate->userProvidedDownloadBuffer + replyPrivate->totalProgress);
137 replyPrivate->totalProgress += haveRead;
140 }
else if (haveRead == 0) {
142 }
else if (haveRead < 0) {
146 }
else if (!replyPrivate->isChunked() && replyPrivate->bodyLength > 0) {
149 qint64 haveRead = replyPrivate->readBodyFast(
m_socket, &replyPrivate->responseData);
151 replyPrivate->totalProgress += haveRead;
152 if (replyPrivate->shouldEmitSignals()) {
161 qint64 haveRead = replyPrivate->readBody(
m_socket, &replyPrivate->responseData);
164 replyPrivate->totalProgress += haveRead;
165 if (replyPrivate->shouldEmitSignals()) {
169 }
else if (haveRead == -1) {
190 }
while (bytes != lastBytes &&
m_reply);
230 qWarning(
"QAbstractProtocolHandler::sendRequest() called without QHttpNetworkReply");
255 replyPrivate->clear();
257 replyPrivate->connectionChannel =
m_channel;
259 replyPrivate->pipeliningUsed =
false;
281#ifndef QT_NO_NETWORKPROXY
291 if (uploadByteDevice) {
318 if (uploadByteDevice)
327 const qint64 socketBufferFill = 32*1024;
328 const qint64 socketWriteMaxSize = 16*1024;
333 const auto encryptedBytesToWrite = [sslSocket]() ->
qint64
335 return sslSocket ? sslSocket->encryptedBytesToWrite() : 0;
338 const auto encryptedBytesToWrite = [](){
return qint64(0); };
348 qint64 currentReadSize = 0;
350 const char *readPointer = uploadByteDevice->
readPointer(desiredReadSize, currentReadSize);
352 if (currentReadSize == -1) {
356 }
else if (readPointer ==
nullptr || currentReadSize == 0) {
362 qWarning() <<
"QHttpProtocolHandler: Internal error in sendRequest. Expected to write at position" <<
m_channel->
written <<
"but read device is at" << uploadByteDevice->
pos();
369 currentWriteSize =
m_socket->
write(readPointer, currentReadSize);
373 m_header.
append(readPointer, currentReadSize);
374 currentWriteSize =
m_socket->
write(std::exchange(m_header, {}));
375 if (currentWriteSize != -1)
379 if (currentWriteSize == -1 || currentWriteSize != currentReadSize) {
404 if (uploadByteDevice) {
IOBluetoothL2CAPChannel * channel
QHttpNetworkReply * m_reply
QHttpNetworkConnectionChannel * m_channel
QHttpNetworkConnection * m_connection
The QAuthenticator class provides an authentication object.
void setUser(const QString &user)
Sets the user used for authentication.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isSocketReading() const
bool isSocketWaiting() const
void handleUnexpectedEOF()
QHttpNetworkReply * reply
QHttpNetworkRequest request
void _q_error(QAbstractSocket::SocketError)
QAuthenticator authenticator
void preConnectFinished()
QHttpNetworkConnection * connection()
void dataSendProgress(qint64 done, qint64 total)
void dataReadProgress(qint64 done, qint64 total)
static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy)
bool isPreConnect() const
void setUrl(const QUrl &url) override
bool withCredentials() const
QUrl url() const override
QNonContiguousByteDevice * uploadByteDevice() const
qint64 contentLength() const override
QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel)
virtual bool sendRequest() override
virtual void _q_receiveReply() override
virtual void _q_readyRead() override
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qint64 peek(char *data, qint64 maxlen)
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual qint64 bytesToWrite() const
For buffered devices, this function returns the number of bytes waiting to be written.
virtual const char * readPointer(qint64 maximumLength, qint64 &len)=0
Return a byte pointer for at most maximumLength bytes of that device.
virtual qint64 pos() const
virtual bool advanceReadPointer(qint64 amount)=0
will advance the internal read pointer by amount bytes.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
QString userInfo(ComponentFormattingOptions options=PrettyDecoded) const
Returns the user info of the URL, or an empty string if the user info is undefined.
QString userName(ComponentFormattingOptions options=FullyDecoded) const
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
QString password(ComponentFormattingOptions=FullyDecoded) const
Returns the password of the URL if it is defined; otherwise an empty string is returned.
void setUserInfo(const QString &userInfo, ParsingMode mode=TolerantMode)
Sets the user info of the URL to userInfo.
QAbstractSocket::SocketError socketError(QIODevice *device)
QAbstractSocket::SocketState socketState(QIODevice *device)
Combined button and popup list for selecting options.
static const qint64 headerSize
constexpr const T & qMin(const T &a, const T &b)
QUrl url("example.com")
[constructor-url-reference]