src/network/access/qhttpnetworkconnectionchannel.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
child 7 3f74d0d4af4c
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
   672     switch (statusCode) {
   672     switch (statusCode) {
   673     case 401: // auth required
   673     case 401: // auth required
   674     case 407: // proxy auth required
   674     case 407: // proxy auth required
   675         if (connection->d_func()->handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) {
   675         if (connection->d_func()->handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) {
   676             if (resend) {
   676             if (resend) {
   677                 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
   677                 if (!resetUploadData())
   678                 if (uploadByteDevice) {
   678                     break;
   679                     if (uploadByteDevice->reset()) {
       
   680                         written = 0;
       
   681                     } else {
       
   682                         connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ContentReSendError);
       
   683                         break;
       
   684                     }
       
   685                 }
       
   686 
   679 
   687                 reply->d_func()->eraseData();
   680                 reply->d_func()->eraseData();
   688 
   681 
   689                 if (alreadyPipelinedRequests.isEmpty()) {
   682                 if (alreadyPipelinedRequests.isEmpty()) {
   690                     // this does a re-send without closing the connection
   683                     // this does a re-send without closing the connection
   709         break;
   702         break;
   710     default:
   703     default:
   711         QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
   704         QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
   712     }
   705     }
   713 }
   706 }
       
   707 
       
   708 bool QHttpNetworkConnectionChannel::resetUploadData()
       
   709 {
       
   710     QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
       
   711     if (!uploadByteDevice)
       
   712         return true;
       
   713 
       
   714     if (uploadByteDevice->reset()) {
       
   715         written = 0;
       
   716         return true;
       
   717     } else {
       
   718         connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ContentReSendError);
       
   719         return false;
       
   720     }
       
   721 }
       
   722 
   714 
   723 
   715 void  QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
   724 void  QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
   716 {
   725 {
   717     // this is only called for simple GET
   726     // this is only called for simple GET
   718 
   727 
   870         // all other errors are treated as NetworkError
   879         // all other errors are treated as NetworkError
   871         errorCode = QNetworkReply::UnknownNetworkError;
   880         errorCode = QNetworkReply::UnknownNetworkError;
   872         break;
   881         break;
   873     }
   882     }
   874     QPointer<QObject> that = connection;
   883     QPointer<QObject> that = connection;
   875     QString errorString = connection->d_func()->errorDetail(errorCode, socket);
   884     QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString());
   876     if (send2Reply) {
   885     if (send2Reply) {
   877         if (reply) {
   886         if (reply) {
   878             reply->d_func()->errorString = errorString;
   887             reply->d_func()->errorString = errorString;
   879             // this error matters only to this reply
   888             // this error matters only to this reply
   880             emit reply->finishedWithError(errorCode, errorString);
   889             emit reply->finishedWithError(errorCode, errorString);