CopperSpice API  1.9.1
QNetworkReply Class Reference

The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager. More...

Inheritance diagram for QNetworkReply:
QIODevice QObject

Public Typedefs

typedef QPair< QByteArray, QByteArrayRawHeaderPair
 
- Public Typedefs inherited from QIODevice
using OpenMode = QFlags< OpenModeFlag >
 

Public Types

enum  NetworkError
 
- Public Types inherited from QIODevice
enum  OpenModeFlag
 

Public Signals

void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 
void encrypted ()
 
void error (QNetworkReply::NetworkError code)
 
void finished ()
 
void metaDataChanged ()
 
void preSharedKeyAuthenticationRequired (QSslPreSharedKeyAuthenticator *authenticator)
 
void redirected (const QUrl &url)
 
void sslErrors (const QList< QSslError > &errors)
 
void uploadProgress (qint64 bytesSent, qint64 bytesTotal)
 
- Public Signals inherited from QIODevice
void aboutToClose ()
 
void bytesWritten (qint64 bytes)
 
void readChannelFinished ()
 
void readyRead ()
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

virtual void abort ()
 
virtual void ignoreSslErrors ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 ~QNetworkReply ()
 
QVariant attribute (QNetworkRequest::Attribute code) const
 
virtual void close () override
 
NetworkError error () const
 
bool hasRawHeader (const QByteArray &headerName) const
 
QVariant header (QNetworkRequest::KnownHeaders header) const
 
void ignoreSslErrors (const QList< QSslError > &errors)
 
bool isFinished () const
 
bool isRunning () const
 
virtual bool isSequential () const override
 
QNetworkAccessManagermanager () const
 
QNetworkAccessManager::Operation operation () const
 
QByteArray rawHeader (const QByteArray &headerName) const
 
QList< QByteArrayrawHeaderList () const
 
const QList< RawHeaderPair > & rawHeaderPairs () const
 
qint64 readBufferSize () const
 
QNetworkRequest request () const
 
virtual void setReadBufferSize (qint64 size)
 
void setSslConfiguration (const QSslConfiguration &configuration)
 
QSslConfiguration sslConfiguration () const
 
QUrl url () const
 
- Public Methods inherited from QIODevice
 QIODevice ()
 
 QIODevice (QObject *parent)
 
virtual ~QIODevice ()
 
virtual bool atEnd () const
 
virtual qint64 bytesAvailable () const
 
virtual qint64 bytesToWrite () const
 
virtual bool canReadLine () const
 
QString errorString () const
 
bool getChar (char *c)
 
bool isOpen () const
 
bool isReadable () const
 
bool isTextModeEnabled () const
 
bool isWritable () const
 
virtual bool open (OpenMode mode)
 
OpenMode openMode () const
 
qint64 peek (char *data, qint64 maxSize)
 
QByteArray peek (qint64 maxSize)
 
virtual qint64 pos () const
 
bool putChar (char c)
 
qint64 read (char *data, qint64 maxSize)
 
QByteArray read (qint64 maxSize)
 
QByteArray readAll ()
 
qint64 readLine (char *data, qint64 maxSize)
 
QByteArray readLine (qint64 maxSize=0)
 
virtual bool reset ()
 
virtual bool seek (qint64 pos)
 
void setTextModeEnabled (bool enabled)
 
virtual qint64 size () const
 
void ungetChar (char c)
 
virtual bool waitForBytesWritten (int msecs)
 
virtual bool waitForReadyRead (int msecs)
 
qint64 write (const char *data)
 
qint64 write (const char *data, qint64 maxSize)
 
qint64 write (const QByteArray &data)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Protected Methods

 QNetworkReply (QObject *parent=nullptr)
 
virtual void ignoreSslErrorsImplementation (const QList< QSslError > &errors)
 
void setAttribute (QNetworkRequest::Attribute code, const QVariant &value)
 
void setError (NetworkError errorCode, const QString &errorString)
 
void setFinished (bool finished)
 
void setHeader (QNetworkRequest::KnownHeaders header, const QVariant &value)
 
void setOperation (QNetworkAccessManager::Operation operation)
 
void setRawHeader (const QByteArray &headerName, const QByteArray &value)
 
void setRequest (const QNetworkRequest &request)
 
virtual void setSslConfigurationImplementation (const QSslConfiguration &configuration)
 
void setUrl (const QUrl &url)
 
virtual void sslConfigurationImplementation (QSslConfiguration &configuration) const
 
virtual qint64 writeData (const char *data, qint64 len) override
 
- Protected Methods inherited from QIODevice
virtual qint64 readData (char *data, qint64 maxSize) = 0
 
virtual qint64 readLineData (char *data, qint64 maxSize)
 
void setErrorString (const QString &errorString)
 
void setOpenMode (OpenMode openMode)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager. This class contains the data and meta data related to a request posted with QNetworkAccessManager. Like QNetworkRequest, it contains a URL and headers (both in parsed and raw form), some information about the reply's state and the contents of the reply itself.

QNetworkReply is a sequential-access QIODevice, which means that once data is read from the object, it no longer kept by the device. It is therefore the application's responsibility to keep this data if it needs to. Whenever more data is received from the network and processed, the readyRead() signal is emitted.

The downloadProgress() signal is also emitted when data is received, but the number of bytes contained in it may not represent the actual bytes received, if any transformation is done to the contents (for example, decompressing and removing the protocol overhead).

Even though QNetworkReply is a QIODevice connected to the contents of the reply, it also emits the uploadProgress() signal, which indicates the progress of the upload for operations that have such content.

Do not delete the object in the slot connected to the error() or finished() signal, use deleteLater().

See also
QNetworkRequest, QNetworkAccessManager

Member Typedef Documentation

RawHeaderPair is a QPair<QByteArray, QByteArray> where the first QByteArray is the header name and the second is the header.

Member Enumeration Documentation

Indicates all possible error conditions found during the processing of the request.

ConstantValueDescription
QNetworkReply::NoError0 No error condition.
When the HTTP protocol returns a redirect no error will be reported. You can check if there is a redirect with the QNetworkRequest::RedirectionTargetAttribute attribute.
QNetworkReply::ConnectionRefusedError1 Remote server refused the connection (the server is not accepting requests)
QNetworkReply::RemoteHostClosedError2 Remote server closed the connection prematurely, before the entire reply was received and processed
QNetworkReply::HostNotFoundError3 Remote host name was not found (invalid hostname)
QNetworkReply::TimeoutError4Connection to the remote server timed out
QNetworkReply::OperationCanceledError5 Operation was canceled via calls to abort() or close() before it was finished.
QNetworkReply::SslHandshakeFailedError6 SSL/TLS handshake failed and the encrypted channel could not be established. The sslErrors() signal should have been emitted.
QNetworkReply::TemporaryNetworkFailureError7 Connection was broken due to disconnection from the network, however the system has initiated roaming to another access point. The request should be resubmitted and will be processed as soon as the connection is re-established.
QNetworkReply::BackgroundRequestNotAllowedError8 Connection was broken due to disconnection from the network or failure to start the network.
QNetworkReply::BackgroundRequestNotAllowedError9 Background request is not currently allowed due to platform policy.
QNetworkReply::TooManyRedirectsError10 While following redirects, the maximum limit was reached. The limit is by default set to 50 or as set by QNetworkRequest::setMaxRedirectsAllowed().
QNetworkReply::InsecureRedirectError11 While following redirects, the network access API detected a redirect from a encrypted protocol (https) to an unencrypted one (http).
QNetworkReply::ProxyConnectionRefusedError101 Connection to the proxy server was refused (the proxy server is not accepting requests)
QNetworkReply::ProxyConnectionClosedError102 Proxy server closed the connection prematurely, before the entire reply was received and processed
QNetworkReply::ProxyNotFoundError103 Proxy host name was not found (invalid proxy hostname)
QNetworkReply::ProxyTimeoutError104 Connection to the proxy timed out or the proxy did not reply in time to the request sent
QNetworkReply::ProxyAuthenticationRequiredError105 Proxy requires authentication in order to honour the request but did not accept any credentials offered (if any)
QNetworkReply::ContentAccessDenied201 Access to the remote content was denied (similar to HTTP error 401)
QNetworkReply::ContentOperationNotPermittedError202 Operation requested on the remote content is not permitted
QNetworkReply::ContentNotFoundError203 Remote content was not found at the server (similar to HTTP error 404)
QNetworkReply::AuthenticationRequiredError204 Remote server requires authentication to serve the content but the credentials provided were not accepted (if any)
QNetworkReply::ContentReSendError205 Request needed to be sent again, but this failed for example because the upload data could not be read a second time.
QNetworkReply::ProtocolUnknownError301 Network Access API can not honor the request because the protocol is not known
QNetworkReply::ProtocolInvalidOperationError302 Requested operation is invalid for this protocol
QNetworkReply::UnknownNetworkError99 Unknown network-related error was detected
QNetworkReply::UnknownProxyError199 Unknown proxy-related error was detected
QNetworkReply::UnknownContentError299 Unknown error related to the remote content was detected
QNetworkReply::ProtocolFailure399 Breakdown in protocol was detected (parsing error, invalid or unexpected responses, etc.)
See also
error()

Constructor & Destructor Documentation

QNetworkReply::~QNetworkReply ( )

Disposes of this reply and frees any resources associated with it. If any network connections are still open, they will be closed.

See also
abort(), close()
QNetworkReply::QNetworkReply ( QObject parent = nullptr)
explicitprotected

Creates a QNetworkReply object with the given parent.

You can not directly instantiate QNetworkReply objects. Use QNetworkAccessManager functions to do that.

Method Documentation

void QNetworkReply::abort ( )
slot

Aborts the operation immediately and close down any network connections still open. Uploads still in progress are also aborted.

See also
close()
QVariant QNetworkReply::attribute ( QNetworkRequest::Attribute  code) const

Returns the attribute associated with the given code. If the attribute has not been set it returns an invalid QVariant (type QVariant::Null). You can expect the default values listed in QNetworkRequest::Attribute to be applied to the values returned by this method.

See also
setAttribute(), QNetworkRequest::Attribute
void QNetworkReply::close ( )
overridevirtual

Closes this device for reading. Unread data is discarded, but the network resources are not discarded until they are finished. In particular, if any upload is in progress, it will continue until it is done.

The finished() signal is emitted when all operations are over and the network resources are freed.

See also
abort(), finished()

Reimplemented from QIODevice::close()

void QNetworkReply::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

This signal is emitted to indicate the progress of the download part of this network request, if there's any. If there's no download associated with this request, this signal will be emitted once with 0 as the value of both bytesReceived and bytesTotal.

The bytesReceived parameter indicates the number of bytes received, while bytesTotal indicates the total number of bytes expected to be downloaded. If the number of bytes to be downloaded is not known, bytesTotal will be -1.

The download is finished when bytesReceived is equal to bytesTotal. At that time, bytesTotal will not be -1.

Note that the values of both bytesReceived and bytesTotal may be different from size(), the total number of bytes obtained through read() or readAll(), or the value of the header(ContentLengthHeader). The reason for that is that there may be protocol overhead or the data may be compressed during the download.

See also
uploadProgress(), bytesAvailable()
void QNetworkReply::encrypted ( )
signal

This signal is emitted when an SSL/TLS session has successfully completed the initial handshake. At this point, no user data has been transmitted. The signal can be used to perform additional checks on the certificate chain, for example to notify users when the certificate for a website has changed. If the reply does not match the expected criteria then it should be aborted by calling QNetworkReply::abort() by a slot connected to this signal. The SSL configuration in use can be inspected using the QNetworkReply::sslConfiguration() method.

Internally, QNetworkAccessManager may open multiple connections to a server, in order to allow it process requests in parallel. These connections may be reused, which means that the encrypted() signal would not be emitted. This means that you are only guaranteed to receive this signal for the first connection to a site in the lifespan of the QNetworkAccessManager.

See also
QSslSocket::encrypted(), QNetworkAccessManager::encrypted()
NetworkError QNetworkReply::error ( ) const

Returns the error that was found during the processing of this request. If no error was found, returns NoError.

See also
setError()
void QNetworkReply::error ( QNetworkReply::NetworkError  code)
signal

This signal is emitted when the reply detects an error in processing. The finished() signal will probably follow, indicating that the connection is over.

The code parameter contains the code of the error that was detected. Call errorString() to obtain a textual representation of the error condition.

Do not delete the object in the slot connected to this signal, use deleteLater().

See also
error(), errorString()
void QNetworkReply::finished ( )
signal

This signal is emitted when the reply has finished processing. After this signal is emitted, there will be no more updates to the reply's data or metadata.

Unless close() has been called, the reply will be still be opened for reading, so the data can be retrieved by calls to read() or readAll(). In particular, if no calls to read() were made as a result of readyRead(), a call to readAll() will retrieve the full contents in a QByteArray.

This signal is emitted in tandem with QNetworkAccessManager::finished() where that signal's reply parameter is this object.

You can also use isFinished() to check if a QNetworkReply has finished even before you receive the finished() signal.

Do not delete the object in the slot connected to this signal, use deleteLater().

See also
setFinished(), QNetworkAccessManager::finished(), isFinished()
bool QNetworkReply::hasRawHeader ( const QByteArray headerName) const

Returns true if the raw header of name headerName was sent by the remote server

See also
rawHeader()
QVariant QNetworkReply::header ( QNetworkRequest::KnownHeaders  header) const

Returns the value of the known header, if that header was sent by the remote server. If the header was not sent, returns an invalid QVariant.

See also
rawHeader(), setHeader(), QNetworkRequest::header()
void QNetworkReply::ignoreSslErrors ( )
slot

If this methods is called, SSL errors related to network connection will be ignored, including certificate validation errors.

Be sure to always let the user inspect the errors reported by the sslErrors() signal, and only call this method upon confirmation from the user that proceeding is ok. If there are unexpected errors, the reply should be aborted. Calling this method without inspecting the actual errors will most likely pose a security risk for your application. Use it with great care.

This method can be called from the slot connected to the sslErrors() signal, which indicates which errors were found.

See also
sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()
void QNetworkReply::ignoreSslErrors ( const QList< QSslError > &  errors)

This method configures QSslSocket to ignore a specific set of errors given in errors. Multiple calls to this method will replace the list of errors that were passed in previous calls. You can clear the list of errors you want to ignore by calling this function with an empty list.

For example, if you want to connect to a Server and allow a self signed certificate use code similar to the following.

QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem");
QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error);
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://server.tld/index.html")));
reply->ignoreSslErrors(expectedSslErrors);

Multiple calls to this method will replace the list of errors that were passed in previous calls. You can clear the list of errors you want to ignore by calling this function with an empty list.

See also
sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()
void QNetworkReply::ignoreSslErrorsImplementation ( const QList< QSslError > &  errors)
protectedvirtual

This virtual method is provided to enable overriding the behavior of ignoreSslErrors(). ignoreSslErrors() is a public wrapper for this method. The value for errors contains the errors the user wants to ignore.

See also
ignoreSslErrors()
bool QNetworkReply::isFinished ( ) const

Returns true when the reply has finished or was aborted.

See also
isRunning()
bool QNetworkReply::isRunning ( ) const

Returns true when the request is still processing and the reply has not finished or was aborted yet.

See also
isFinished()
virtual bool QNetworkReply::isSequential ( ) const
overridevirtual

Returns true if this device is sequential, otherwise returns false.

Sequential devices, as opposed to a random-access devices, have no concept of a start, an end, a size, or a current position, and they do not support seeking. You can only read from the device when it reports that data is available. The most common example of a sequential device is a network socket. On Unix, special files such as /dev/zero and fifo pipes are sequential.

Regular files, on the other hand, do support random access. They have both a size and a current position, and they also support seeking backwards and forwards in the data stream. Regular files are non-sequential.

The QIODevice implementation returns false.

See also
bytesAvailable()

Reimplemented from QIODevice::isSequential()

QNetworkAccessManager * QNetworkReply::manager ( ) const

Returns the QNetworkAccessManager that was used to create this QNetworkReply object. Initially, it is also the parent object.

void QNetworkReply::metaDataChanged ( )
signal

This signal is emitted whenever the metadata in this reply changes. metadata is any information that is not the content (data) itself, including the network headers. In the majority of cases, the metadata will be known fully by the time the first byte of data is received. However, it is possible to receive updates of headers or other metadata during the processing of the data.

See also
header(), rawHeaderList(), rawHeader(), hasRawHeader()
QNetworkAccessManager::Operation QNetworkReply::operation ( ) const

Returns the operation that was posted for this reply.

See also
setOperation()
void QNetworkReply::preSharedKeyAuthenticationRequired ( QSslPreSharedKeyAuthenticator authenticator)
signal

This signal is emitted if the SSL/TLS handshake negotiates a PSK ciphersuite, and therefore a PSK authentication is then required.

When using PSK, the client must send to the server a valid identity and a valid pre shared key, in order for the SSL handshake to continue. Applications can provide this information in a slot connected to this signal, by filling in the passed authenticator object according to their needs.

Ignoring this signal, or failing to provide the required credentials, will cause the handshake to fail, and therefore the connection to be aborted.

The authenticator object is owned by the reply and must not be deleted by the application.

See also
QSslPreSharedKeyAuthenticator
QByteArray QNetworkReply::rawHeader ( const QByteArray headerName) const

Returns the raw contents of the header headerName as sent by the remote server. If there is no such header, returns an empty byte array, which may be indistinguishable from an empty header. Use hasRawHeader() to verify if the server sent such header field.

See also
setRawHeader(), hasRawHeader(), header()
QList< QByteArray > QNetworkReply::rawHeaderList ( ) const

Returns a list of headers fields that were sent by the remote server, in the order that they were sent. Duplicate headers are merged together and take place of the latter duplicate.

const QList< RawHeaderPair > & QNetworkReply::rawHeaderPairs ( ) const

Returns a list of raw header pairs.

qint64 QNetworkReply::readBufferSize ( ) const

Returns the size of the read buffer, in bytes.

See also
setReadBufferSize()
void QNetworkReply::redirected ( const QUrl url)
signal

This signal is only emitted if the setAttribute() method has been called with the enum value of QNetworkRequest::FollowRedirectsAttribute. The signal indicates the server responded with a 3xx status with a valid url in the location header, indicating a HTTP redirect. The url parameter contains the new redirect url as returned by the server in the location header.

See also
QNetworkRequest::Attribute
QNetworkRequest QNetworkReply::request ( ) const

Returns the request that was posted for this reply. In special, note that the URL for the request may be different than that of the reply.

See also
QNetworkRequest::url(), url(), setRequest()
void QNetworkReply::setAttribute ( QNetworkRequest::Attribute  code,
const QVariant value 
)
protected

Sets the attribute code to the given value. If code was previously set, it will be overridden. If value is an invalid QVariant the attribute will be unset.

See also
attribute(), QNetworkRequest::setAttribute()
void QNetworkReply::setError ( NetworkError  errorCode,
const QString errorString 
)
protected

Sets the error condition to be errorCode. The human readable message is set with errorString. Calling setError() does not emit the error(QNetworkReply::NetworkError) signal.

See also
error(), errorString()
void QNetworkReply::setFinished ( bool  finished)
protected

Sets the reply as finished. After having this set the replies data must not change.

See also
finished(), isFinished()
void QNetworkReply::setHeader ( QNetworkRequest::KnownHeaders  header,
const QVariant value 
)
protected

Sets the known header to the given value. The corresponding raw form of the header will be set as well.

See also
header(), setRawHeader(), QNetworkRequest::setHeader()
void QNetworkReply::setOperation ( QNetworkAccessManager::Operation  operation)
protected

Sets the associated operation for this object to be operation. This value will be returned by operation(). The operation should be set when this object is created and not changed again.

See also
operation(), setRequest()
void QNetworkReply::setRawHeader ( const QByteArray headerName,
const QByteArray value 
)
protected

Sets the raw header headerName to be the given value. If headerName was previously set it is overridden. Multiple HTTP headers of the same name are functionally equivalent to one single header with the values concatenated, separated by commas.

If headerName matches a known header, the value will be parsed and the corresponding parsed form will also be set.

See also
rawHeader(), header(), setHeader(), QNetworkRequest::setRawHeader()
void QNetworkReply::setReadBufferSize ( qint64  size)
virtual

Sets the size of the read buffer to be size bytes. The read buffer is the buffer that holds data that is being downloaded off the network, before it is read with QIODevice::read(). Setting the buffer size to 0 will make the buffer unlimited in size.

QNetworkReply will try to stop reading from the network once this buffer is full (i.e., bytesAvailable() returns size or more), thus causing the download to throttle down as well. If the buffer is not limited in size, QNetworkReply will try to download as fast as possible from the network.

Unlike QAbstractSocket::setReadBufferSize(), QNetworkReply can not guarantee precision in the read buffer size. That is, bytesAvailable() can return more than size.

See also
readBufferSize()
void QNetworkReply::setRequest ( const QNetworkRequest request)
protected

Sets the associated request for this object to be request. This value will be returned by request().

Note: the request should be set when this object is created and not changed again.

See also
request(), setOperation()
void QNetworkReply::setSslConfiguration ( const QSslConfiguration configuration)

Sets the SSL configuration for the network connection associated with this request, if possible, to be that of configuration.

See also
sslConfiguration()
void QNetworkReply::setSslConfigurationImplementation ( const QSslConfiguration configuration)
protectedvirtual

This virtual method is provided to enable overriding the behavior of setSslConfiguration(). setSslConfiguration() is a public wrapper for this method. If you override this method use configuration to set the SSL configuration.

See also
sslConfigurationImplementation(), setSslConfiguration()
void QNetworkReply::setUrl ( const QUrl url)
protected

Sets the URL being processed to be url. Normally, the URL matches that of the request that was posted, but for a variety of reasons it can be different (for example, a file path being made absolute or canonical).

See also
url(), request(), QNetworkRequest::url()
QSslConfiguration QNetworkReply::sslConfiguration ( ) const

Returns the SSL configuration and state associated with this reply, if SSL was used. It will contain the remote server's certificate, its certificate chain leading to the Certificate Authority as well as the encryption ciphers in use.

The peer's certificate and its certificate chain will be known by the time sslErrors() is emitted, if it's emitted.

See also
setSslConfiguration()
void QNetworkReply::sslConfigurationImplementation ( QSslConfiguration configuration) const
protectedvirtual

This virtual method is provided to enable overriding the behavior of sslConfiguration(). sslConfiguration() is a public wrapper for this method. The configuration will be returned in configuration.

See also
sslConfiguration()
void QNetworkReply::sslErrors ( const QList< QSslError > &  errors)
signal

This signal is emitted if the SSL/TLS session encountered errors during the set up, including certificate verification errors. The errors parameter contains the list of errors.

To indicate that the errors are not fatal and that the connection should proceed, the ignoreSslErrors() function should be called from the slot connected to this signal. If it is not called, the SSL session will be torn down before any data is exchanged (including the URL).

This signal can be used to display an error message to the user indicating that security may be compromised and display the SSL settings (see sslConfiguration() to obtain it). If the user decides to proceed after analyzing the remote certificate, the slot should call ignoreSslErrors().

See also
QSslSocket::sslErrors(), QNetworkAccessManager::sslErrors(), sslConfiguration(), ignoreSslErrors()
void QNetworkReply::uploadProgress ( qint64  bytesSent,
qint64  bytesTotal 
)
signal

This signal is emitted to indicate the progress of the upload part of this network request, if there's any. If there's no upload associated with this request, this signal will not be emitted.

The bytesSent parameter indicates the number of bytes uploaded, while bytesTotal indicates the total number of bytes to be uploaded. If the number of bytes to be uploaded could not be determined, bytesTotal will be -1.

The upload is finished when bytesSent is equal to bytesTotal. At that time, bytesTotal will not be -1.

See also
downloadProgress()
QUrl QNetworkReply::url ( ) const

Returns the URL of the content downloaded or uploaded. Note that the URL may be different from that of the original request.

See also
request(), setUrl(), QNetworkRequest::url()
virtual qint64 QNetworkReply::writeData ( const char *  data,
qint64  maxSize 
)
overrideprotectedvirtual

Writes up to maxSize bytes from data to the device. Returns the number of bytes written, or -1 if an error occurred.

This method is called by QIODevice. Reimplement when creating a subclass of QIODevice. When reimplementing it is important that this method writes all the data available before returning. This is required in order for QDataStream to be able to operate on the class. QDataStream assumes all the information was written and therefore does not retry writing if there was a problem.

See also
read(), write()

Implements QIODevice::writeData()