Qt 4.8
Public Functions | List of all members
QNetworkReplyImpl Class Reference

#include <qnetworkreplyimpl_p.h>

Inheritance diagram for QNetworkReplyImpl:
QNetworkReply QIODevice QObject

Public Functions

virtual void abort ()
 Aborts the operation immediately and close down any network connections still open. More...
 
virtual qint64 bytesAvailable () const
 Returns the number of bytes available for reading with QIODevice::read(). More...
 
virtual bool canReadLine () const
 Returns true if a complete line of data can be read from the device; otherwise returns false. More...
 
virtual void close ()
 Closes this device for reading. More...
 
virtual bool event (QEvent *)
 
virtual void ignoreSslErrors ()
 If this function is called, SSL errors related to network connection will be ignored, including certificate validation errors. More...
 
virtual Q_INVOKABLE void ignoreSslErrorsImplementation (const QList< QSslError > &errors)
 
 QNetworkReplyImpl (QObject *parent=0)
 
virtual qint64 readData (char *data, qint64 maxlen)
 
virtual void setReadBufferSize (qint64 size)
 Sets the size of the read buffer to be size bytes. More...
 
Q_INVOKABLE void setSslConfigurationImplementation (const QSslConfiguration &configuration)
 
Q_INVOKABLE QSslConfiguration sslConfigurationImplementation () const
 
 ~QNetworkReplyImpl ()
 
- Public Functions inherited from QNetworkReply
QVariant attribute (QNetworkRequest::Attribute code) const
 Returns the attribute associated with the code code. More...
 
NetworkError error () const
 Returns the error that was found during the processing of this request. More...
 
bool hasRawHeader (const QByteArray &headerName) const
 Returns true if the raw header of name headerName was sent by the remote server. More...
 
QVariant header (QNetworkRequest::KnownHeaders header) const
 Returns the value of the known header header, if that header was sent by the remote server. More...
 
void ignoreSslErrors (const QList< QSslError > &errors)
 If this function is called, the SSL errors given in errors will be ignored. More...
 
bool isFinished () const
 Returns true when the reply has finished or was aborted. More...
 
bool isRunning () const
 Returns true when the request is still processing and the reply has not finished or was aborted yet. More...
 
virtual bool isSequential () const
 
QNetworkAccessManagermanager () const
 Returns the QNetworkAccessManager that was used to create this QNetworkReply object. More...
 
QNetworkAccessManager::Operation operation () const
 Returns the operation that was posted for this reply. More...
 
QByteArray rawHeader (const QByteArray &headerName) const
 Returns the raw contents of the header headerName as sent by the remote server. More...
 
QList< QByteArrayrawHeaderList () const
 Returns a list of headers fields that were sent by the remote server, in the order that they were sent. More...
 
const QList< RawHeaderPair > & rawHeaderPairs () const
 Returns a list of raw header pairs. More...
 
qint64 readBufferSize () const
 Returns the size of the read buffer, in bytes. More...
 
QNetworkRequest request () const
 Returns the request that was posted for this reply. More...
 
void setSslConfiguration (const QSslConfiguration &configuration)
 Sets the SSL configuration for the network connection associated with this request, if possible, to be that of config. More...
 
QSslConfiguration sslConfiguration () const
 Returns the SSL configuration and state associated with this reply, if SSL was used. More...
 
QUrl url () const
 Returns the URL of the content downloaded or uploaded. More...
 
 ~QNetworkReply ()
 Disposes of this reply and frees any resources associated with it. More...
 
- Public Functions inherited from QIODevice
virtual bool atEnd () const
 Returns true if the current read and write position is at the end of the device (i.e. More...
 
virtual qint64 bytesToWrite () const
 For buffered devices, this function returns the number of bytes waiting to be written. More...
 
QString errorString () const
 Returns a human-readable description of the last device error that occurred. More...
 
bool getChar (char *c)
 Reads one character from the device and stores it in c. More...
 
bool isOpen () const
 Returns true if the device is open; otherwise returns false. More...
 
bool isReadable () const
 Returns true if data can be read from the device; otherwise returns false. More...
 
bool isTextModeEnabled () const
 Returns true if the Text flag is enabled; otherwise returns false. More...
 
bool isWritable () const
 Returns true if data can be written to the device; otherwise returns false. More...
 
virtual bool open (OpenMode mode)
 Opens the device and sets its OpenMode to mode. More...
 
OpenMode openMode () const
 Returns the mode in which the device has been opened; i.e. More...
 
qint64 peek (char *data, qint64 maxlen)
 Reads at most maxSize bytes from the device into data, without side effects (i. More...
 
QByteArray peek (qint64 maxlen)
 Peeks at most maxSize bytes from the device, returning the data peeked as a QByteArray. More...
 
virtual qint64 pos () const
 For random-access devices, this function returns the position that data is written to or read from. More...
 
bool putChar (char c)
 Writes the character c to the device. More...
 
 QIODevice ()
 Constructs a QIODevice object. More...
 
 QIODevice (QObject *parent)
 Constructs a QIODevice object with the given parent. More...
 
qint64 read (char *data, qint64 maxlen)
 Reads at most maxSize bytes from the device into data, and returns the number of bytes read. More...
 
QByteArray read (qint64 maxlen)
 Reads at most maxSize bytes from the device, and returns the data read as a QByteArray. More...
 
QByteArray readAll ()
 Reads all available data from the device, and returns it as a QByteArray. More...
 
qint64 readLine (char *data, qint64 maxlen)
 This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes, stores the characters in data, and returns the number of bytes read. More...
 
QByteArray readLine (qint64 maxlen=0)
 Reads a line from the device, but no more than maxSize characters, and returns the result as a QByteArray. More...
 
virtual bool reset ()
 Seeks to the start of input for random-access devices. More...
 
virtual bool seek (qint64 pos)
 For random-access devices, this function sets the current position to pos, returning true on success, or false if an error occurred. More...
 
void setTextModeEnabled (bool enabled)
 If enabled is true, this function sets the Text flag on the device; otherwise the Text flag is removed. More...
 
virtual qint64 size () const
 For open random-access devices, this function returns the size of the device. More...
 
void ungetChar (char c)
 Puts the character c back into the device, and decrements the current position unless the position is 0. More...
 
virtual bool waitForBytesWritten (int msecs)
 For buffered devices, this function waits until a payload of buffered written data has been written to the device and the bytesWritten() signal has been emitted, or until msecs milliseconds have passed. More...
 
virtual bool waitForReadyRead (int msecs)
 Blocks until new data is available for reading and the readyRead() signal has been emitted, or until msecs milliseconds have passed. More...
 
qint64 write (const char *data, qint64 len)
 Writes at most maxSize bytes of data from data to the device. More...
 
qint64 write (const char *data)
 Writes data from a zero-terminated string of 8-bit characters to the device. More...
 
qint64 write (const QByteArray &data)
 Writes the content of byteArray to the device. More...
 
virtual ~QIODevice ()
 The destructor is virtual, and QIODevice is an abstract base class. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Additional Inherited Members

- Public Types inherited from QNetworkReply
enum  NetworkError {
  NoError = 0, ConnectionRefusedError = 1, RemoteHostClosedError, HostNotFoundError,
  TimeoutError, OperationCanceledError, SslHandshakeFailedError, TemporaryNetworkFailureError,
  UnknownNetworkError = 99, ProxyConnectionRefusedError = 101, ProxyConnectionClosedError, ProxyNotFoundError,
  ProxyTimeoutError, ProxyAuthenticationRequiredError, UnknownProxyError = 199, ContentAccessDenied = 201,
  ContentOperationNotPermittedError, ContentNotFoundError, AuthenticationRequiredError, ContentReSendError,
  UnknownContentError = 299, ProtocolUnknownError = 301, ProtocolInvalidOperationError, ProtocolFailure = 399
}
 Indicates all possible error conditions found during the processing of the request. More...
 
typedef QPair< QByteArray, QByteArrayRawHeaderPair
 RawHeaderPair is a QPair<QByteArray, QByteArray> where the first QByteArray is the header name and the second is the header. More...
 
- Public Types inherited from QIODevice
enum  OpenModeFlag {
  NotOpen = 0x0000, ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = ReadOnly | WriteOnly,
  Append = 0x0004, Truncate = 0x0008, Text = 0x0010, Unbuffered = 0x0020
}
 This enum is used with open() to describe the mode in which a device is opened. More...
 
- Public Slots inherited from QNetworkReply
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QNetworkReply
void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 This signal is emitted to indicate the progress of the download part of this network request, if there's any. More...
 
void error (QNetworkReply::NetworkError)
 This signal is emitted when the reply detects an error in processing. More...
 
void finished ()
 This signal is emitted when the reply has finished processing. More...
 
void metaDataChanged ()
 This signal is emitted whenever the metadata in this reply changes. More...
 
void sslErrors (const QList< QSslError > &errors)
 This signal is emitted if the SSL/TLS session encountered errors during the set up, including certificate verification errors. More...
 
void uploadProgress (qint64 bytesSent, qint64 bytesTotal)
 This signal is emitted to indicate the progress of the upload part of this network request, if there's any. More...
 
- Signals inherited from QIODevice
void aboutToClose ()
 This signal is emitted when the device is about to close. More...
 
void bytesWritten (qint64 bytes)
 This signal is emitted every time a payload of data has been written to the device. More...
 
void readChannelFinished ()
 This signal is emitted when the input (reading) stream is closed in this device. More...
 
void readyRead ()
 This signal is emitted once every time new data is available for reading from the device. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QNetworkReply
 QNetworkReply (QObject *parent=0)
 Creates a QNetworkReply object with parent parent. More...
 
 QNetworkReply (QNetworkReplyPrivate &dd, QObject *parent)
 
void setAttribute (QNetworkRequest::Attribute code, const QVariant &value)
 Sets the attribute code to have value value. More...
 
void setError (NetworkError errorCode, const QString &errorString)
 Sets the error condition to be errorCode. More...
 
void setFinished (bool)
 Sets the reply as finished. More...
 
void setHeader (QNetworkRequest::KnownHeaders header, const QVariant &value)
 Sets the known header header to be of value value. More...
 
void setOperation (QNetworkAccessManager::Operation operation)
 Sets the associated operation for this object to be operation. More...
 
void setRawHeader (const QByteArray &headerName, const QByteArray &value)
 Sets the raw header headerName to be of value value. More...
 
void setRequest (const QNetworkRequest &request)
 Sets the associated request for this object to be request. More...
 
void setUrl (const QUrl &url)
 Sets the URL being processed to be url. More...
 
virtual qint64 writeData (const char *data, qint64 len)
 
- Protected Functions inherited from QIODevice
 QIODevice (QIODevicePrivate &dd, QObject *parent=0)
 
virtual qint64 readLineData (char *data, qint64 maxlen)
 Reads up to maxSize characters into data and returns the number of characters read. More...
 
void setErrorString (const QString &errorString)
 Sets the human readable description of the last device error that occurred to str. More...
 
void setOpenMode (OpenMode openMode)
 Sets the OpenMode of the device to openMode. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 73 of file qnetworkreplyimpl_p.h.

Constructors and Destructors

◆ QNetworkReplyImpl()

QNetworkReplyImpl::QNetworkReplyImpl ( QObject parent = 0)

Definition at line 850 of file qnetworkreplyimpl.cpp.

852 {
853 }
QNetworkReply(QObject *parent=0)
Creates a QNetworkReply object with parent parent.

◆ ~QNetworkReplyImpl()

QNetworkReplyImpl::~QNetworkReplyImpl ( )

Definition at line 855 of file qnetworkreplyimpl.cpp.

856 {
858 
859  // This code removes the data from the cache if it was prematurely aborted.
860  // See QNetworkReplyImplPrivate::completeCacheSave(), we disable caching there after the cache
861  // save had been properly finished. So if it is still enabled it means we got deleted/aborted.
862  if (d->isCachingEnabled())
863  d->networkCache()->remove(url());
864 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QUrl url() const
Returns the URL of the content downloaded or uploaded.

Functions

◆ abort()

void QNetworkReplyImpl::abort ( )
virtual

Aborts the operation immediately and close down any network connections still open.

Uploads still in progress are also aborted.

See also
close()

Implements QNetworkReply.

Definition at line 866 of file qnetworkreplyimpl.cpp.

867 {
870  return;
871 
872  // stop both upload and download
873  if (d->outgoingData)
874  disconnect(d->outgoingData, 0, this, 0);
875  if (d->copyDevice)
876  disconnect(d->copyDevice, 0, this, 0);
877 
879 
880  if (d->state != QNetworkReplyImplPrivate::Finished) {
881  // call finished which will emit signals
882  d->error(OperationCanceledError, tr("Operation canceled"));
885  d->finished();
886  }
888 
889  // finished may access the backend
890  if (d->backend) {
891  d->backend->deleteLater();
892  d->backend = 0;
893  }
894 }
double d
Definition: qnumeric_p.h:62
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void close()
Closes this device for reading.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895

◆ bytesAvailable()

qint64 QNetworkReplyImpl::bytesAvailable ( ) const
virtual

Returns the number of bytes available for reading with QIODevice::read().

The number of bytes available may grow until the finished() signal is emitted.

Reimplemented from QIODevice.

Definition at line 928 of file qnetworkreplyimpl.cpp.

929 {
930  // Special case for the "zero copy" download buffer
931  Q_D(const QNetworkReplyImpl);
932  if (d->downloadBuffer) {
933  qint64 maxAvail = d->downloadBufferCurrentSize - d->downloadBufferReadPosition;
934  return QNetworkReply::bytesAvailable() + maxAvail;
935  }
936 
937  return QNetworkReply::bytesAvailable() + d_func()->readBuffer.byteAmount();
938 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
__int64 qint64
Definition: qglobal.h:942
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
Definition: qiodevice.cpp:752

◆ canReadLine()

bool QNetworkReplyImpl::canReadLine ( ) const
virtual

Returns true if a complete line of data can be read from the device; otherwise returns false.

Note that unbuffered devices, which have no way of determining what can be read, always return false.

This function is often called in conjunction with the readyRead() signal.

Subclasses that reimplement this function must call the base implementation in order to include the contents of the QIODevice's buffer. Example:

bool CustomDevice::canReadLine() const
{
return buffer.contains('\n') || QIODevice::canReadLine();
}
See also
readyRead(), readLine()

Reimplemented from QIODevice.

Definition at line 916 of file qnetworkreplyimpl.cpp.

917 {
918  Q_D(const QNetworkReplyImpl);
919  return QNetworkReply::canReadLine() || d->readBuffer.canReadLine();
920 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false...
Definition: qiodevice.cpp:1330

◆ close()

void QNetworkReplyImpl::close ( )
virtual

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 QNetworkReply.

Definition at line 896 of file qnetworkreplyimpl.cpp.

897 {
899  if (d->state == QNetworkReplyImplPrivate::Aborted ||
901  return;
902 
903  // stop the download
904  if (d->backend)
905  d->backend->closeDownstreamChannel();
906  if (d->copyDevice)
907  disconnect(d->copyDevice, 0, this, 0);
908 
910 
911  // call finished which will emit signals
912  d->error(OperationCanceledError, tr("Operation canceled"));
913  d->finished();
914 }
double d
Definition: qnumeric_p.h:62
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void close()
Closes this device for reading.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895

◆ event()

bool QNetworkReplyImpl::event ( QEvent e)
virtual
Warning
This function is not part of the public interface. Reimplemented for internal purposes

Reimplemented from QObject.

Definition at line 1029 of file qnetworkreplyimpl.cpp.

1030 {
1031  if (e->type() == QEvent::NetworkReplyUpdated) {
1032  d_func()->handleNotifications();
1033  return true;
1034  }
1035 
1036  return QObject::event(e);
1037 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ ignoreSslErrors()

void QNetworkReplyImpl::ignoreSslErrors ( )
virtual

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

Warning
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 function can be called from the slot connected to the sslErrors() signal, which indicates which errors were found.

See also
sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()

Reimplemented from QNetworkReply.

Definition at line 972 of file qnetworkreplyimpl.cpp.

973 {
975  if (d->backend)
976  d->backend->ignoreSslErrors();
977 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ ignoreSslErrorsImplementation()

void QNetworkReplyImpl::ignoreSslErrorsImplementation ( const QList< QSslError > &  errors)
virtual

Definition at line 979 of file qnetworkreplyimpl.cpp.

980 {
982  if (d->backend)
983  d->backend->ignoreSslErrors(errors);
984 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ readData()

qint64 QNetworkReplyImpl::readData ( char *  data,
qint64  maxlen 
)
virtual
Warning
This function is not part of the public interface.

Implements QIODevice.

Definition at line 990 of file qnetworkreplyimpl.cpp.

991 {
993 
994  // Special case code if we have the "zero copy" download buffer
995  if (d->downloadBuffer) {
996  qint64 maxAvail = qMin<qint64>(d->downloadBufferCurrentSize - d->downloadBufferReadPosition, maxlen);
997  if (maxAvail == 0)
998  return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0;
999  // FIXME what about "Aborted" state?
1000  qMemCopy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);
1001  d->downloadBufferReadPosition += maxAvail;
1002  return maxAvail;
1003  }
1004 
1005 
1006  if (d->readBuffer.isEmpty())
1007  return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0;
1008  // FIXME what about "Aborted" state?
1009 
1011  if (maxlen == 1) {
1012  // optimization for getChar()
1013  *data = d->readBuffer.getChar();
1014  if (d->backend && readBufferSize())
1015  d->backend->emitReadBufferFreed(1);
1016  return 1;
1017  }
1018 
1019  maxlen = qMin<qint64>(maxlen, d->readBuffer.byteAmount());
1020  qint64 bytesRead = d->readBuffer.read(data, maxlen);
1021  if (d->backend && readBufferSize())
1022  d->backend->emitReadBufferFreed(bytesRead);
1023  return bytesRead;
1024 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 readBufferSize() const
Returns the size of the read buffer, in bytes.
static const char * data(const QByteArray &arr)
__int64 qint64
Definition: qglobal.h:942
void * qMemCopy(void *dest, const void *src, size_t n)
Definition: qglobal.cpp:2508

◆ setReadBufferSize()

void QNetworkReplyImpl::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 cannot guarantee precision in the read buffer size. That is, bytesAvailable() can return more than size.

See also
readBufferSize()

Reimplemented from QNetworkReply.

Definition at line 940 of file qnetworkreplyimpl.cpp.

941 {
943  if (size > d->readBufferMaxSize &&
944  size > d->readBuffer.byteAmount())
946 
948 
949  if (d->backend) {
950  d->backend->setDownstreamLimited(d->readBufferMaxSize > 0);
951  d->backend->setReadBufferSize(size);
952  }
953 }
double d
Definition: qnumeric_p.h:62
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
Definition: qiodevice.cpp:642
virtual void setReadBufferSize(qint64 size)
Sets the size of the read buffer to be size bytes.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setSslConfigurationImplementation()

void QNetworkReplyImpl::setSslConfigurationImplementation ( const QSslConfiguration configuration)

Definition at line 965 of file qnetworkreplyimpl.cpp.

966 {
968  if (d->backend && !config.isNull())
969  d->backend->setSslConfiguration(config);
970 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ sslConfigurationImplementation()

QSslConfiguration QNetworkReplyImpl::sslConfigurationImplementation ( ) const

Definition at line 956 of file qnetworkreplyimpl.cpp.

957 {
958  Q_D(const QNetworkReplyImpl);
959  QSslConfiguration config;
960  if (d->backend)
961  d->backend->fetchSslConfiguration(config);
962  return config;
963 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QSslConfiguration class holds the configuration and state of an SSL connection.

The documentation for this class was generated from the following files: