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
qnetworkreplyimpl.cpp
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
6#include "qnetworkcookie.h"
7#include "qnetworkcookiejar.h"
9#include "QtCore/qcoreapplication.h"
10#include "QtCore/qdatetime.h"
11#include "QtNetwork/qsslconfiguration.h"
13
14#include <QtCore/QCoreApplication>
15
17
18QT_IMPL_METATYPE_EXTERN_TAGGED(QSharedPointer<char>, QSharedPointer_char)
19
21 : backend(nullptr), outgoingData(nullptr),
22 copyDevice(nullptr),
23 cacheEnabled(false), cacheSaveDevice(nullptr),
24 notificationHandlingPaused(false),
25 bytesDownloaded(0), bytesUploaded(-1),
26 httpStatusCode(0),
27 state(Idle)
28 , downloadBufferReadPosition(0)
29 , downloadBufferCurrentSize(0)
30 , downloadBufferMaximumSize(0)
31 , downloadBuffer(nullptr)
32{
34 emitAllUploadProgressSignals = true;
35}
36
38{
39 // ensure this function is only being called once
40 if (state == Working || state == Finished) {
41 qDebug() << "QNetworkReplyImpl::_q_startOperation was called more than once" << url;
42 return;
43 }
44 state = Working;
45
46 // note: if that method is called directly, it cannot happen that the backend is 0,
47 // because we just checked via a qobject_cast that we got a http backend (see
48 // QNetworkReplyImplPrivate::setup())
49 if (!backend) {
51 QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); // not really true!;
52 finished();
53 return;
54 }
55
56 if (!backend->start()) {
57 qWarning("Backend start failed");
58 state = Working;
60 QCoreApplication::translate("QNetworkReply", "backend start error."));
61 finished();
62 return;
63 }
64
65 // Prepare timer for progress notifications
68
69 if (backend && backend->isSynchronous()) {
71 q_func()->setFinished(true);
72 } else {
73 if (state != Finished) {
76
78 }
79 }
80}
81
83{
85 if (state != Working)
86 return;
87 if (!copyDevice || !q->isOpen())
88 return;
89
90 // FIXME Optimize to use download buffer if it is a QBuffer.
91 // Needs to be done where sendCacheContents() (?) of HTTP is emitting
92 // metaDataChanged ?
93 qint64 lastBytesDownloaded = bytesDownloaded;
94 forever {
95 qint64 bytesToRead = nextDownstreamBlockSize();
96 if (bytesToRead == 0)
97 // we'll be called again, eventually
98 break;
99
100 bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());
101 qint64 bytesActuallyRead = copyDevice->read(buffer.reserve(bytesToRead), bytesToRead);
102 if (bytesActuallyRead == -1) {
103 buffer.chop(bytesToRead);
104 break;
105 }
106 buffer.chop(bytesToRead - bytesActuallyRead);
107
108 if (!copyDevice->isSequential() && copyDevice->atEnd()) {
109 bytesDownloaded += bytesActuallyRead;
110 break;
111 }
112
113 bytesDownloaded += bytesActuallyRead;
114 }
115
116 if (bytesDownloaded == lastBytesDownloaded) {
117 // we didn't read anything
118 return;
119 }
120
121 const auto totalSizeOpt = QNetworkHeadersPrivate::toInt(
123
125 // emit readyRead before downloadProgress in case this will cause events to be
126 // processed and we get into a recursive call (as in QProgressDialog).
127 emit q->readyRead();
130 emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1));
131 }
133}
134
139
141{
143
144 // make sure this is only called once, ever.
145 //_q_bufferOutgoingData may call it or the readChannelFinished emission
146 if (state != Buffering)
147 return;
148
149 // disconnect signals
152
153 // finally, start the request
154 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
155}
156
158{
160
161 if (!outgoingDataBuffer) {
162 // first call, create our buffer
163 outgoingDataBuffer = std::make_shared<QRingBuffer>();
164
167 }
168
169 qint64 bytesBuffered = 0;
170 qint64 bytesToBuffer = 0;
171
172 // read data into our buffer
173 forever {
174 bytesToBuffer = outgoingData->bytesAvailable();
175 // unknown? just try 2 kB, this also ensures we always try to read the EOF
176 if (bytesToBuffer <= 0)
177 bytesToBuffer = 2*1024;
178
179 char *dst = outgoingDataBuffer->reserve(bytesToBuffer);
180 bytesBuffered = outgoingData->read(dst, bytesToBuffer);
181
182 if (bytesBuffered == -1) {
183 // EOF has been reached.
184 outgoingDataBuffer->chop(bytesToBuffer);
185
187 break;
188 } else if (bytesBuffered == 0) {
189 // nothing read right now, just wait until we get called again
190 outgoingDataBuffer->chop(bytesToBuffer);
191
192 break;
193 } else {
194 // don't break, try to read() again
195 outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered);
196 }
197 }
198}
199
202{
204
206 request = req;
207 originalRequest = req;
208 url = request.url();
209 operation = op;
210
211 q->QIODevice::open(QIODevice::ReadOnly);
212 // Internal code that does a HTTP reply for the synchronous Ajax
213 // in Qt WebKit.
214 QVariant synchronousHttpAttribute = req.attribute(
216 // The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer.
217 // Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway.
218 if (synchronousHttpAttribute.toBool() && outgoingData) {
219 outgoingDataBuffer = std::make_shared<QRingBuffer>();
220 qint64 previousDataSize = 0;
221 do {
222 previousDataSize = outgoingDataBuffer->size();
224 } while (outgoingDataBuffer->size() != previousDataSize);
225 }
226
227 if (backend)
228 backend->setSynchronous(synchronousHttpAttribute.toBool());
229
230
231 if (outgoingData && backend && !backend->isSynchronous()) {
232 // there is data to be uploaded, e.g. HTTP POST.
233
235 // backend does not need upload buffering or
236 // fixed size non-sequential
237 // just start the operation
238 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
239 } else {
240 bool bufferingDisallowed =
242 false).toBool();
243
244 if (bufferingDisallowed) {
245 // if a valid content-length header for the request was supplied, we can disable buffering
246 // if not, we will buffer anyway
247 const auto sizeOpt = QNetworkHeadersPrivate::toInt(
249
250 if (sizeOpt) {
251 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
252 } else {
254 QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection);
255 }
256 } else {
257 // _q_startOperation will be called when the buffering has finished.
259 QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection);
260 }
261 }
262 } else {
263 // for HTTP, we want to send out the request as fast as possible to the network, without
264 // invoking methods in a QueuedConnection
265 if (backend && backend->isSynchronous())
267 else
268 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
269 }
270}
271
273{
275 const auto it = std::find(pendingNotifications.cbegin(), pendingNotifications.cend(), notification);
277 pendingNotifications.push_back(notification);
278
279 if (pendingNotifications.size() == 1)
281}
282
284{
286 return;
287
288 for (InternalNotifications notification : std::exchange(pendingNotifications, {})) {
289 if (state != Working)
290 return;
291 switch (notification) {
293 if (copyDevice) {
295 } else if (backend) {
296 if (backend->bytesAvailable() > 0)
298 else if (backend->wantToRead())
300 }
301 break;
302 }
303 }
304}
305
306// Do not handle the notifications while we are emitting downloadProgress
307// or readyRead
312
313// Resume notification handling
321
323{
324 if (!backend)
325 return nullptr;
326 return backend->networkCache();
327}
328
330{
331 // check if we can save and if we're allowed to
332 if (!networkCache()
334 return;
335 cacheEnabled = true;
336}
337
339{
340 return (cacheEnabled && networkCache() != nullptr);
341}
342
344{
345 if (!enable && !cacheEnabled)
346 return; // nothing to do
347 if (enable && cacheEnabled)
348 return; // nothing to do either!
349
350 if (enable) {
352 // refuse to enable in this case
353 qCritical("QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written");
354 return;
355 }
356
357 createCache();
358 } else {
359 // someone told us to turn on, then back off?
360 // ok... but you should make up your mind
361 qDebug("QNetworkReplyImpl: setCachingEnabled(true) called after setCachingEnabled(false) -- "
362 "backend %s probably needs to be fixed",
363 backend->metaObject()->className());
365 cacheSaveDevice = nullptr;
366 cacheEnabled = false;
367 }
368}
369
380
382{
384 bytesUploaded = bytesSent;
385
387 //choke signal emissions, except the first and last signals which are unconditional
389 if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) {
390 return;
391 }
393 } else {
395 }
396 }
397
399 emit q->uploadProgress(bytesSent, bytesTotal);
401}
402
403
405{
406 enum { DesiredBufferSize = 32 * 1024 };
407 if (readBufferMaxSize == 0)
408 return DesiredBufferSize;
409
410 return qMax<qint64>(0, readBufferMaxSize - buffer.size());
411}
412
414{
416
417 // The disk cache does not support partial content, so don't even try to
418 // save any such content into the cache.
419 if (q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206) {
420 cacheEnabled = false;
421 return;
422 }
423
424 // save the meta data
425 QNetworkCacheMetaData metaData;
426 metaData.setUrl(url);
427 // @todo @future: fetchCacheMetaData is not currently implemented in any backend, but can be useful again in the future
428 // metaData = backend->fetchCacheMetaData(metaData);
429
430 // save the redirect request also in the cache
431 QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);
432 if (redirectionTarget.isValid()) {
435 metaData.setAttributes(attributes);
436 }
437
438 cacheSaveDevice = networkCache()->prepare(metaData);
439
442 qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
443 "class %s probably needs to be fixed",
445
447 cacheSaveDevice = nullptr;
448 cacheEnabled = false;
449 }
450}
451
452// we received downstream data and send this to the cache
453// and to our buffer (which in turn gets read by the user of QNetworkReply)
455{
457 if (!q->isOpen())
458 return;
459
462 }
463
465 for (qsizetype i = 0; i < data.bufferCount(); ++i) {
466 QByteArray const &item = data[i];
467
468 if (cacheSaveDevice)
469 cacheSaveDevice->write(item.constData(), item.size());
470 buffer.append(item);
471
472 bytesWritten += item.size();
473 }
474 data.clear();
475
477
479}
480
482{
484
485 const auto totalSizeOpt = QNetworkHeadersPrivate::toInt(
488 // important: At the point of this readyRead(), the data parameter list must be empty,
489 // else implicit sharing will trigger memcpy when the user is reading data!
490 emit q->readyRead();
491 // emit readyRead before downloadProgress in case this will cause events to be
492 // processed and we get into a recursive call (as in QProgressDialog).
495 emit q->downloadProgress(bytesDownloaded, totalSizeOpt.value_or(-1));
496 }
497
499 // do we still have room in the buffer?
500 if (nextDownstreamBlockSize() > 0)
502}
503
504// this is used when it was fetched from the cache, right?
506{
508 if (!q->isOpen())
509 return;
510
511 // read until EOF from data
512 if (Q_UNLIKELY(copyDevice)) {
513 qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
514 "backend probably needs to be fixed");
515 return;
516 }
517
519 q->connect(copyDevice, SIGNAL(readyRead()), SLOT(_q_copyReadyRead()));
520 q->connect(copyDevice, SIGNAL(readChannelFinished()), SLOT(_q_copyReadChannelFinished()));
521
522 // start the copy:
524}
525
527{
529
530 if (!downloadBuffer) {
531 // We are requested to create it
532 // Check attribute() if allocating a buffer of that size can be allowed
534 if (bufferAllocationPolicy.isValid() && bufferAllocationPolicy.toLongLong() >= size) {
537 downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails
538 downloadBufferPointer = QSharedPointer<char>(downloadBuffer, [](auto p) { delete[] p; });
539
541 }
542 }
543
544 return downloadBuffer;
545}
546
557
558
560{
562 if (!q->isOpen())
563 return;
564
567
568 if (cacheSaveDevice && bytesReceived == bytesTotal) {
569 // Write everything in one go if we use a download buffer. might be more performant.
571 }
572
573 bytesDownloaded = bytesReceived;
574
575 downloadBufferCurrentSize = bytesReceived;
576
577 // Only emit readyRead when actual data is there
578 // emit readyRead before downloadProgress in case this will cause events to be
579 // processed and we get into a recursive call (as in QProgressDialog).
580 if (bytesDownloaded > 0)
581 emit q->readyRead();
584 emit q->downloadProgress(bytesDownloaded, bytesTotal);
585 }
586}
587
589{
591
592 if (state == Finished || state == Aborted)
593 return;
594
596 const auto totalSizeOpt = QNetworkHeadersPrivate::toInt(
598 const auto totalSize = totalSizeOpt.value_or(-1);
599
601
602 state = Finished;
603 q->setFinished(true);
604
605 pendingNotifications.clear();
606
608 if (totalSize == -1) {
609 emit q->downloadProgress(bytesDownloaded, bytesDownloaded);
610 } else {
611 emit q->downloadProgress(bytesDownloaded, totalSize);
612 }
613
615 emit q->uploadProgress(0, 0);
617
618 // if we don't know the total size of or we received everything save the cache
619 if (totalSize == -1 || bytesDownloaded == totalSize)
621
622 // note: might not be a good idea, since users could decide to delete us
623 // which would delete the backend too...
624 // maybe we should protect the backend
626 emit q->readChannelFinished();
627 emit q->finished();
629}
630
632{
634 // Can't set and emit multiple errors.
636 qWarning( "QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.");
637 return;
638 }
639
640 errorCode = code;
641 q->setErrorString(errorMessage);
642
643 // note: might not be a good idea, since users could decide to delete us
644 // which would delete the backend too...
645 // maybe we should protect the backend
646 emit q->errorOccurred(code);
647}
648
650{
652 // 1. do we have cookies?
653 // 2. are we allowed to set them?
654 if (!manager.isNull()) {
655 const auto cookiesOpt = QNetworkHeadersPrivate::toSetCookieList(
657 const auto cookies = cookiesOpt.value_or(QList<QNetworkCookie>());
658 if (!cookies.empty()
662 if (jar) {
663 jar->setCookiesFromUrl(cookies, url);
664 }
665 }
666 }
667
668 emit q->metaDataChanged();
669}
670
675
677{
678#ifndef QT_NO_SSL
680 emit q->encrypted();
681#endif
682}
683
684void QNetworkReplyImplPrivate::sslErrors(const QList<QSslError> &errors)
685{
686#ifndef QT_NO_SSL
688 emit q->sslErrors(errors);
689#else
690 Q_UNUSED(errors);
691#endif
692}
693
695{
697 if (!backend)
698 return;
699
701 if (backend->bytesAvailable())
702 emit q->readyRead();
703 } else {
704 bool anyBytesRead = false;
705 while (backend->bytesAvailable()
706 && (!readBufferMaxSize || buffer.size() < readBufferMaxSize)) {
708 if (toRead == 0)
709 toRead = 16 * 1024; // try to read something
710 char *data = buffer.reserve(toRead);
711 qint64 bytesRead = backend->read(data, toRead);
712 Q_ASSERT(bytesRead <= toRead);
713 buffer.chop(toRead - bytesRead);
714 anyBytesRead |= bytesRead > 0;
715 }
716 if (anyBytesRead)
717 emit q->readyRead();
718 }
719}
720
725
727{
729
730 // This code removes the data from the cache if it was prematurely aborted.
731 // See QNetworkReplyImplPrivate::completeCacheSave(), we disable caching there after the cache
732 // save had been properly finished. So if it is still enabled it means we got deleted/aborted.
733 if (d->isCachingEnabled())
734 d->networkCache()->remove(url());
735}
736
738{
741 return;
742
743 // stop both upload and download
744 if (d->outgoingData)
745 disconnect(d->outgoingData, nullptr, this, nullptr);
746 if (d->copyDevice)
747 disconnect(d->copyDevice, nullptr, this, nullptr);
748
750
751 // call finished which will emit signals
752 d->error(OperationCanceledError, tr("Operation canceled"));
753 d->finished();
755
756 // finished may access the backend
757 if (d->backend) {
758 d->backend->deleteLater();
759 d->backend = nullptr;
760 }
761}
762
764{
766 if (d->state == QNetworkReplyPrivate::Aborted ||
768 return;
769
770 // stop the download
771 if (d->backend)
772 d->backend->close();
773 if (d->copyDevice)
774 disconnect(d->copyDevice, nullptr, this, nullptr);
775
777
778 // call finished which will emit signals
779 d->error(OperationCanceledError, tr("Operation canceled"));
780 d->finished();
781}
782
789{
790 // Special case for the "zero copy" download buffer
791 Q_D(const QNetworkReplyImpl);
792 if (d->downloadBuffer) {
793 qint64 maxAvail = d->downloadBufferCurrentSize - d->downloadBufferReadPosition;
794 return QNetworkReply::bytesAvailable() + maxAvail;
795 }
796 return QNetworkReply::bytesAvailable() + (d->backend ? d->backend->bytesAvailable() : 0);
797}
798
800{
802 qint64 oldMaxSize = d->readBufferMaxSize;
804 if (size > oldMaxSize && size > d->buffer.size())
805 d->readFromBackend();
806}
807
808#ifndef QT_NO_SSL
809void QNetworkReplyImpl::sslConfigurationImplementation(QSslConfiguration &configuration) const
810{
811 Q_D(const QNetworkReplyImpl);
812 if (d->backend)
813 configuration = d->backend->sslConfiguration();
814}
815
817{
819 if (d->backend && !config.isNull())
820 d->backend->setSslConfiguration(config);
821}
822
824{
826 if (d->backend)
827 d->backend->ignoreSslErrors();
828}
829
830void QNetworkReplyImpl::ignoreSslErrorsImplementation(const QList<QSslError> &errors)
831{
833 if (d->backend)
834 d->backend->ignoreSslErrors(errors);
835}
836#endif // QT_NO_SSL
837
842{
844
845 if (d->backend
846 && d->backend->ioFeatures().testFlag(QNetworkAccessBackend::IOFeature::ZeroCopy)) {
847 qint64 bytesRead = 0;
848 while (d->backend->bytesAvailable()) {
849 QByteArrayView view = d->backend->readPointer();
850 if (view.size()) {
851 qint64 bytesToCopy = qMin(qint64(view.size()), maxlen - bytesRead);
852 memcpy(data + bytesRead, view.data(), bytesToCopy); // from zero to one copy
853
854 // We might have to cache this
855 if (d->cacheEnabled && !d->cacheSaveDevice)
856 d->initCacheSaveDevice();
857 if (d->cacheEnabled && d->cacheSaveDevice)
858 d->cacheSaveDevice->write(view.data(), view.size());
859
860 bytesRead += bytesToCopy;
861 d->backend->advanceReadPointer(bytesToCopy);
862 } else {
863 break;
864 }
865 }
866
867 const auto totalSizeOpt = QNetworkHeadersPrivate::toInt(
869 emit downloadProgress(bytesRead, totalSizeOpt.value_or(-1));
870 return bytesRead;
871 } else if (d->backend && d->backend->bytesAvailable()) {
872 return d->backend->read(data, maxlen);
873 }
874
875 // Special case code if we have the "zero copy" download buffer
876 if (d->downloadBuffer) {
877 qint64 maxAvail = qMin<qint64>(d->downloadBufferCurrentSize - d->downloadBufferReadPosition, maxlen);
878 if (maxAvail == 0)
879 return d->state == QNetworkReplyPrivate::Finished ? -1 : 0;
880 // FIXME what about "Aborted" state?
881 memcpy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);
882 d->downloadBufferReadPosition += maxAvail;
883 return maxAvail;
884 }
885
886
887 // FIXME what about "Aborted" state?
888 if (d->state == QNetworkReplyPrivate::Finished)
889 return -1;
890
892 return 0;
893}
894
899{
900 if (e->type() == QEvent::NetworkReplyUpdated) {
901 d_func()->handleNotifications();
902 return true;
903 }
904
905 return QObject::event(e);
906}
907
909
910#include "moc_qnetworkreplyimpl_p.cpp"
911
The QAbstractNetworkCache class provides the interface for cache implementations.
virtual void insert(QIODevice *device)=0
Inserts the data in device and the prepared meta data into the cache.
virtual QIODevice * prepare(const QNetworkCacheMetaData &metaData)=0
Returns the device that should be populated with the data for the cache item metaData.
virtual bool remove(const QUrl &url)=0
Removes the cache entry for url, returning true if success otherwise false.
\inmodule QtCore
Definition qbytearray.h:57
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
void invalidate() noexcept
Marks this QElapsedTimer object as invalid.
qint64 elapsed() const noexcept
Returns the number of milliseconds since this QElapsedTimer was last started.
qint64 restart() noexcept
Restarts the timer and returns the number of milliseconds elapsed since the previous start.
void start() noexcept
\typealias QElapsedTimer::Duration Synonym for std::chrono::nanoseconds.
bool isValid() const noexcept
Returns false if the timer has never been started or invalidated by a call to invalidate().
\inmodule QtCore
Definition qcoreevent.h:45
@ NetworkReplyUpdated
Definition qcoreevent.h:231
Type type() const
Returns the event type.
Definition qcoreevent.h:304
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
\inmodule QtCore \reentrant
Definition qiodevice.h:34
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
bool isOpen() const
Returns true if the device is open; otherwise returns false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
virtual qint64 read(char *data, qint64 maxlen)
Implement this function to support reading from the resource made available by your plugin.
virtual bool start()
Prepares the backend and calls open().
bool needsResetableUploadData() const noexcept
virtual bool wantToRead()
This is called before we read if there are no bytes available and we are ready to read more.
virtual qint64 bytesAvailable() const =0
You must implement this function in your derived class.
QAbstractNetworkCache * networkCache() const
Returns the network cache object that was available when the request was started.
IOFeatures ioFeatures() const noexcept
Returns the I/O features that the backend claims to support.
Operation
Indicates the operation this reply is processing.
QNetworkCookieJar * cookieJar() const
Returns the QNetworkCookieJar that is used to store cookies obtained from the network as well as cook...
The QNetworkCacheMetaData class provides cache information.
void setUrl(const QUrl &url)
Sets the URL this network cache meta data to be url.
AttributesMap attributes() const
void setAttributes(const AttributesMap &attributes)
The QNetworkCookieJar class implements a simple jar of QNetworkCookie objects.
virtual bool setCookiesFromUrl(const QList< QNetworkCookie > &cookieList, const QUrl &url)
Adds the cookies in the list cookieList to this cookie jar.
static std::optional< qint64 > toInt(QByteArrayView value)
QHttpHeaders headers() const
static std::optional< NetworkCookieList > toSetCookieList(const QList< QByteArray > &values)
std::vector< InternalNotifications > pendingNotifications
void setDownloadBuffer(QSharedPointer< char > sp, qint64 size)
void error(QNetworkReply::NetworkError code, const QString &errorString)
void appendDownstreamDataDownloadBuffer(qint64, qint64)
QSharedPointer< char > downloadBufferPointer
QNetworkAccessBackend * backend
void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal)
void backendNotify(InternalNotifications notification)
std::shared_ptr< QRingBuffer > outgoingDataBuffer
QAbstractNetworkCache * networkCache() const
void appendDownstreamData(QByteDataBuffer &data)
char * getDownloadBuffer(qint64 size)
void sslErrors(const QList< QSslError > &errors)
void redirectionRequested(const QUrl &target)
void setCachingEnabled(bool enable)
virtual qint64 bytesAvailable() const override
Returns the number of bytes available for reading with QIODevice::read().
virtual qint64 readData(char *data, qint64 maxlen) override
QNetworkReplyImpl(QObject *parent=nullptr)
virtual void ignoreSslErrorsImplementation(const QList< QSslError > &errors) override
virtual void setReadBufferSize(qint64 size) override
Sets the size of the read buffer to be size bytes.
virtual void close() override
Closes this device for reading.
virtual void abort() override
Aborts the operation immediately and close down any network connections still open.
virtual bool event(QEvent *) override
void void void void _q_bufferOutgoingDataFinished()) protected void setSslConfigurationImplementation(const QSslConfiguration &configuration) override
virtual void ignoreSslErrors() override
If this function is called, SSL errors related to network connection will be ignored,...
QPointer< QNetworkAccessManager > manager
QElapsedTimer downloadProgressSignalChoke
QNetworkRequest request
static const int progressSignalInterval
QNetworkAccessManager::Operation operation
QNetworkRequest originalRequest
QElapsedTimer uploadProgressSignalChoke
QNetworkReply::NetworkError errorCode
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
virtual void setReadBufferSize(qint64 size)
Sets the size of the read buffer to be size bytes.
virtual void close() override
Closes this device for reading.
QHttpHeaders headers() const
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
This signal is emitted to indicate the progress of the download part of this network request,...
NetworkError
Indicates all possible error conditions found during the processing of the request.
QUrl url() const
Returns the URL of the content downloaded or uploaded.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
@ EmitAllUploadProgressSignalsAttribute
QVariant attribute(Attribute code, const QVariant &defaultValue=QVariant()) const
Returns the attribute associated with the code code.
QUrl url() const
Returns the URL this network request is referring to.
QDynamicMetaObjectData * metaObject
Definition qobject.h:90
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
bool isNull() const noexcept
Definition qpointer.h:84
const_iterator cend() const noexcept
Definition qset.h:142
T * data() const noexcept
Returns the value of the pointer referenced by this object.
The QSslConfiguration class holds the configuration and state of an SSL connection.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
QString scheme() const
Returns the scheme of the URL.
Definition qurl.cpp:1991
\inmodule QtCore
Definition qvariant.h:65
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
QSet< QString >::iterator it
else opt state
[0]
Combined button and popup list for selecting options.
@ QueuedConnection
#define Q_UNLIKELY(x)
DBusConnection const char DBusError * error
EGLConfig config
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define forever
Definition qforeach.h:78
#define qCritical
Definition qlogging.h:167
#define qDebug
[1]
Definition qlogging.h:164
#define qWarning
Definition qlogging.h:166
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1384
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLenum GLsizei GLuint GLint * bytesWritten
GLenum GLsizei GLsizei GLint * values
[15]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint buffer
GLenum GLenum dst
GLenum target
GLboolean enable
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int void * arg
#define sp
#define tr(X)
#define emit
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition)
Definition qurl.cpp:3517
const char className[16]
[1]
Definition qwizard.cpp:100
myObject disconnect()
[26]
QGraphicsItem * item
QNetworkRequest request(url)
QQuickView * view
[0]
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...