Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qnetworkreply.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
4#include <QtNetwork/private/qtnetworkglobal_p.h>
5
6#include "qnetworkreply.h"
7#include "qnetworkreply_p.h"
8#include <QtNetwork/qsslconfiguration.h>
9
11
13
15
17 : readBufferMaxSize(0),
18 emitAllUploadProgressSignals(false),
19 operation(QNetworkAccessManager::UnknownOperation),
20 errorCode(QNetworkReply::NoError)
21 , isFinished(false)
22{
23 // set the default attribute values
25}
26
27
437{
438}
439
444 : QIODevice(dd, parent)
445{
446}
447
456{
457}
458
471{
473}
474
479{
480 return true;
481}
482
489{
490 return d_func()->readBufferMaxSize;
491}
492
512{
513 Q_D(QNetworkReply);
514 d->readBufferMaxSize = size;
515}
516
522{
523 return d_func()->manager;
524}
525
534{
535 return d_func()->originalRequest;
536}
537
544{
545 return d_func()->operation;
546}
547
555{
556 return d_func()->errorCode;
557}
558
567{
568 return d_func()->isFinished;
569}
570
580{
581 return !isFinished();
582}
583
594{
595 return d_func()->url;
596}
597
606{
607 return d_func()->cookedHeaders.value(header);
608}
609
617{
618 Q_D(const QNetworkReply);
619 return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
620}
621
632{
633 Q_D(const QNetworkReply);
635 d->findRawHeader(headerName);
636 if (it != d->rawHeaders.constEnd())
637 return it->second;
638 return QByteArray();
639}
640
651{
652 Q_D(const QNetworkReply);
653 return d->rawHeaders;
654}
655
662{
663 return d_func()->rawHeadersKeys();
664}
665
677{
678 return d_func()->attributes.value(code);
679}
680
681#if QT_CONFIG(ssl)
691QSslConfiguration QNetworkReply::sslConfiguration() const
692{
694 sslConfigurationImplementation(config);
695 return config;
696}
697
702void QNetworkReply::setSslConfiguration(const QSslConfiguration &config)
703{
704 setSslConfigurationImplementation(config);
705}
706
733{
734 ignoreSslErrorsImplementation(errors);
735}
736
747void QNetworkReply::sslConfigurationImplementation(QSslConfiguration &) const
748{
749}
750
761void QNetworkReply::setSslConfigurationImplementation(const QSslConfiguration &)
762{
763}
764
775void QNetworkReply::ignoreSslErrorsImplementation(const QList<QSslError> &)
776{
777}
778
779#endif // QT_CONFIG(ssl)
780
804{
805}
806
811{
812 return -1; // you can't write
813}
814
825{
826 Q_D(QNetworkReply);
827 d->operation = operation;
828}
829
840{
841 Q_D(QNetworkReply);
842 d->originalRequest = request;
843}
844
854void QNetworkReply::setError(NetworkError errorCode, const QString &errorString)
855{
856 Q_D(QNetworkReply);
857 d->errorCode = errorCode;
858 setErrorString(errorString); // in QIODevice
859}
860
869void QNetworkReply::setFinished(bool finished)
870{
871 Q_D(QNetworkReply);
872 d->isFinished = finished;
873}
874
875
885{
886 Q_D(QNetworkReply);
887 d->url = url;
888}
889
897{
898 Q_D(QNetworkReply);
899 d->setCookedHeader(header, value);
900}
901
914{
915 Q_D(QNetworkReply);
916 d->setRawHeader(headerName, value);
917}
918
927{
928 Q_D(QNetworkReply);
929 if (value.isValid())
930 d->attributes.insert(code, value);
931 else
932 d->attributes.remove(code);
933}
934
936
937#include "moc_qnetworkreply.cpp"
\inmodule QtCore
Definition qbytearray.h:57
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1283
\inmodule QtCore \reentrant
Definition qiodevice.h:34
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
void setErrorString(const QString &errorString)
Sets the human readable description of the last device error that occurred to str.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition qlist.h:74
const_iterator ConstIterator
Definition qlist.h:251
The QNetworkAccessManager class allows the application to send network requests and receive replies.
Operation
Indicates the operation this reply is processing.
static const int progressSignalInterval
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.
QNetworkAccessManager * manager() const
Returns the QNetworkAccessManager that was used to create this QNetworkReply object.
QByteArray rawHeader(const QByteArray &headerName) const
Returns the raw contents of the header headerName as sent by the remote server.
void setError(NetworkError errorCode, const QString &errorString)
Sets the error condition to be errorCode.
bool isFinished() const
virtual void close() override
Closes this device for reading.
QNetworkAccessManager::Operation operation() const
Returns the operation that was posted for this reply.
QVariant attribute(QNetworkRequest::Attribute code) const
Returns the attribute associated with the code code.
qint64 readBufferSize() const
Returns the size of the read buffer, in bytes.
virtual bool isSequential() const override
void setOperation(QNetworkAccessManager::Operation operation)
Sets the associated operation for this object to be operation.
bool isRunning() const
void setUrl(const QUrl &url)
Sets the URL being processed to be url.
NetworkError error() const
Returns the error that was found during the processing of this request.
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
Sets the raw header headerName to be of value value.
QNetworkReply(QObject *parent=nullptr)
Creates a QNetworkReply object with parent parent.
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value)
Sets the attribute code to have value value.
QVariant header(QNetworkRequest::KnownHeaders header) const
Returns the value of the known header header, if that header was sent by the remote server.
void setRequest(const QNetworkRequest &request)
Sets the associated request for this object to be request.
NetworkError
Indicates all possible error conditions found during the processing of the request.
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
Sets the known header header to be of value value.
void setFinished(bool)
bool hasRawHeader(const QByteArray &headerName) const
Returns true if the raw header of name headerName was sent by the remote server.
virtual void ignoreSslErrors()
If this function is called, SSL errors related to network connection will be ignored,...
QList< QByteArray > rawHeaderList() const
Returns a list of headers fields that were sent by the remote server, in the order that they were sen...
void finished()
This signal is emitted when the reply has finished processing.
QNetworkRequest request() const
Returns the request that was posted for this reply.
virtual qint64 writeData(const char *data, qint64 len) override
~QNetworkReply()
Disposes of this reply and frees any resources associated with it.
QUrl url() const
Returns the URL of the content downloaded or uploaded.
const QList< RawHeaderPair > & rawHeaderPairs() const
Returns a list of raw header pairs.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
KnownHeaders
List of known header types that QNetworkRequest parses.
\inmodule QtCore
Definition qobject.h:90
The QSslConfiguration class holds the configuration and state of an SSL connection.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
QString url(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Definition qurl.cpp:2814
\inmodule QtCore
Definition qvariant.h:64
T value() const &
Definition qvariant.h:511
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QString header(const QString &name)
EGLConfig config
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1363
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLenum GLuint GLintptr GLsizeiptr size
[1]
@ NoError
Definition main.cpp:34
long long qint64
Definition qtypes.h:55
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent