src/network/access/qnetworkreplyimpl.cpp
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 14 c0432d11811c
child 23 89e065397ea6
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtNetwork module of the Qt Toolkit.
     7 ** This file is part of the QtNetwork module of the Qt Toolkit.
     8 **
     8 **
    70         qDebug("QNetworkReplyImpl::_q_startOperation was called more than once");
    70         qDebug("QNetworkReplyImpl::_q_startOperation was called more than once");
    71         return;
    71         return;
    72     }
    72     }
    73     state = Working;
    73     state = Working;
    74 
    74 
       
    75     // note: if that method is called directly, it cannot happen that the backend is 0,
       
    76     // because we just checked via a qobject_cast that we got a http backend (see
       
    77     // QNetworkReplyImplPrivate::setup())
    75     if (!backend) {
    78     if (!backend) {
    76         error(QNetworkReplyImpl::ProtocolUnknownError,
    79         error(QNetworkReplyImpl::ProtocolUnknownError,
    77               QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); // not really true!;
    80               QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); // not really true!;
    78         finished();
    81         finished();
    79         return;
    82         return;
   200             // don't break, try to read() again
   203             // don't break, try to read() again
   201             outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered);
   204             outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered);
   202         }
   205         }
   203     }
   206     }
   204 }
   207 }
   205 
       
   206 
   208 
   207 void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,
   209 void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,
   208                                      QIODevice *data)
   210                                      QIODevice *data)
   209 {
   211 {
   210     Q_Q(QNetworkReplyImpl);
   212     Q_Q(QNetworkReplyImpl);
   244         }
   246         }
   245     } else {
   247     } else {
   246         // No outgoing data (e.g. HTTP GET request)
   248         // No outgoing data (e.g. HTTP GET request)
   247         // or no backend
   249         // or no backend
   248         // if no backend, _q_startOperation will handle the error of this
   250         // if no backend, _q_startOperation will handle the error of this
   249         QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
   251 
       
   252         // for HTTP, we want to send out the request as fast as possible to the network, without
       
   253         // invoking methods in a QueuedConnection
       
   254         if (qobject_cast<QNetworkAccessHttpBackend *>(backend)) {
       
   255             _q_startOperation();
       
   256         } else {
       
   257             QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
       
   258         }
   250     }
   259     }
   251 
   260 
   252     q->QIODevice::open(QIODevice::ReadOnly);
   261     q->QIODevice::open(QIODevice::ReadOnly);
   253 }
   262 }
   254 
   263 
   641     if (size > d->readBufferMaxSize &&
   650     if (size > d->readBufferMaxSize &&
   642         size > d->readBuffer.byteAmount())
   651         size > d->readBuffer.byteAmount())
   643         d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
   652         d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
   644 
   653 
   645     QNetworkReply::setReadBufferSize(size);
   654     QNetworkReply::setReadBufferSize(size);
       
   655 
       
   656     if (d->backend)
       
   657         d->backend->setDownstreamLimited(d->readBufferMaxSize > 0);
   646 }
   658 }
   647 
   659 
   648 #ifndef QT_NO_OPENSSL
   660 #ifndef QT_NO_OPENSSL
   649 QSslConfiguration QNetworkReplyImpl::sslConfigurationImplementation() const
   661 QSslConfiguration QNetworkReplyImpl::sslConfigurationImplementation() const
   650 {
   662 {