- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/src/network/access/qhttpnetworkconnectionchannel.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 167 167 #endif 168 168 socket->write(header); 169 170 169 171 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice(); 170 172 if (uploadByteDevice) { … … 259 261 // this is needed if the sends an reply before we have finished sending the request. In that 260 262 // case receiveReply had been called before but ignored the server reply 261 receiveReply();263 ); 262 264 break; 263 265 } … … 273 275 274 276 275 void QHttpNetworkConnectionChannel:: receiveReply()277 void QHttpNetworkConnectionChannel::receiveReply() 276 278 { 277 279 Q_ASSERT(socket); … … 325 327 break; 326 328 } 327 case QHttpNetworkReplyPrivate::ReadingHeaderState: 328 bytes += reply->d_func()->readHeader(socket); 329 if (reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) { 330 if (reply->d_func()->isGzipped() && reply->d_func()->autoDecompress) { 329 case QHttpNetworkReplyPrivate::ReadingHeaderState: { 330 QHttpNetworkReplyPrivate *replyPrivate = reply->d_func(); 331 bytes += replyPrivate->readHeader(socket); 332 if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) { 333 if (replyPrivate->isGzipped() && replyPrivate->autoDecompress) { 331 334 // remove the Content-Length from header 332 reply ->d_func()->removeAutoDecompressHeader();335 reply->removeAutoDecompressHeader(); 333 336 } else { 334 reply ->d_func()->autoDecompress = false;337 reply->autoDecompress = false; 335 338 } 336 if (reply && reply->d_func()->statusCode == 100) {337 reply ->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;339 if (reply->statusCode == 100) { 340 reply->state = QHttpNetworkReplyPrivate::ReadingStatusState; 338 341 break; // ignore 339 342 } 340 if (reply ->d_func()->shouldEmitSignals())343 if (reply->shouldEmitSignals()) 341 344 emit reply->headerChanged(); 342 if (!reply ->d_func()->expectContent()) {343 reply ->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;345 if (!reply->expectContent()) { 346 reply->state = QHttpNetworkReplyPrivate::AllDoneState; 344 347 this->state = QHttpNetworkConnectionChannel::IdleState; 345 348 allDone(); … … 348 351 } 349 352 break; 353 350 354 case QHttpNetworkReplyPrivate::ReadingDataState: { 351 if (!reply->d_func()->isChunked() && !reply->d_func()->autoDecompress 352 && reply->d_func()->bodyLength > 0) { 355 QHttpNetworkReplyPrivate *replyPrivate = reply->d_func(); 356 if (replyPrivate->downstreamLimited && !replyPrivate->responseData.isEmpty() && replyPrivate->shouldEmitSignals()) { 357 // We already have some HTTP body data. We don't read more from the socket until 358 // this is fetched by QHttpNetworkAccessHttpBackend. If we would read more, 359 // we could not limit our read buffer usage. 360 // We only do this when shouldEmitSignals==true because our HTTP parsing 361 // always needs to parse the 401/407 replies. Therefore they don't really obey 362 // to the read buffer maximum size, but we don't care since they should be small. 363 return; 364 } 365 366 if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress 367 && replyPrivate->bodyLength > 0) { 353 368 // bulk files like images should fulfill these properties and 354 369 // we can therefore save on memory copying 355 bytes = reply ->d_func()->readBodyFast(socket, &reply->d_func()->responseData);356 reply ->d_func()->totalProgress += bytes;357 if (reply ->d_func()->shouldEmitSignals()) {370 bytes = reply->responseData); 371 reply->totalProgress += bytes; 372 if (reply->shouldEmitSignals()) { 358 373 QPointer<QHttpNetworkReply> replyPointer = reply; 359 374 emit reply->readyRead(); … … 361 376 if (replyPointer.isNull()) 362 377 return; 363 emit reply->dataReadProgress(reply ->d_func()->totalProgress, reply->d_func()->bodyLength);378 emit reply->dataReadProgress(reply->bodyLength); 364 379 // make sure that the reply is valid 365 380 if (replyPointer.isNull()) … … 372 387 // no content-length etc) 373 388 QByteDataBuffer byteDatas; 374 bytes = reply ->d_func()->readBody(socket, &byteDatas);389 bytes = reply->readBody(socket, &byteDatas); 375 390 if (bytes) { 376 if (reply ->d_func()->autoDecompress)377 reply ->d_func()->appendCompressedReplyData(byteDatas);391 if (reply->autoDecompress) 392 reply->appendCompressedReplyData(byteDatas); 378 393 else 379 reply ->d_func()->appendUncompressedReplyData(byteDatas);380 381 if (!reply ->d_func()->autoDecompress) {382 reply ->d_func()->totalProgress += bytes;383 if (reply ->d_func()->shouldEmitSignals()) {394 reply->appendUncompressedReplyData(byteDatas); 395 396 if (!reply->autoDecompress) { 397 reply->totalProgress += bytes; 398 if (reply->shouldEmitSignals()) { 384 399 QPointer<QHttpNetworkReply> replyPointer = reply; 385 400 // important: At the point of this readyRead(), the byteDatas list must be empty, … … 389 404 if (replyPointer.isNull()) 390 405 return; 391 emit reply->dataReadProgress(reply ->d_func()->totalProgress, reply->d_func()->bodyLength);406 emit reply->dataReadProgress(reply->bodyLength); 392 407 // make sure that the reply is valid 393 408 if (replyPointer.isNull()) … … 402 417 } 403 418 } 404 if (reply ->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState)419 if (reply->state == QHttpNetworkReplyPrivate::ReadingDataState) 405 420 break; 406 421 // everything done, fall through … … 418 433 bool QHttpNetworkConnectionChannel::ensureConnection() 419 434 { 435 436 437 438 439 440 441 442 443 444 445 446 447 448 420 449 // make sure that this socket is in a connected state, if not initiate 421 450 // connection to the host. 422 if (socket ->state()!= QAbstractSocket::ConnectedState) {451 if (socket != QAbstractSocket::ConnectedState) { 423 452 // connect to the host if not already connected. 424 // resend this request after we receive the disconnected signal425 if (socket->state() == QAbstractSocket::ClosingState) {426 resendCurrent = true;427 return false;428 }429 453 state = QHttpNetworkConnectionChannel::ConnectingState; 430 454 pendingEncrypt = connection->d_func()->encrypt; … … 568 592 569 593 // continue reading 570 receiveReply();594 receiveReply(); 571 595 } 572 596 } else if (alreadyPipelinedRequests.isEmpty() && socket->bytesAvailable() > 0) { … … 617 641 { 618 642 char c; 619 while (socket->bytesAvailable()) { 620 if (socket->peek(&c, 1) != 1) 643 do { 644 qint64 ret = socket->peek(&c, 1); 645 646 // nothing read, fine. 647 if (ret == 0) 621 648 return; 649 650 651 652 622 653 623 654 // read all whitespace and line endings … … 628 659 break; 629 660 } 630 } 661 } 631 662 } 632 663 … … 740 771 state = QHttpNetworkConnectionChannel::ReadingState; 741 772 if (reply) 742 receiveReply();773 receiveReply(); 743 774 } 744 775 } … … 759 790 state = QHttpNetworkConnectionChannel::ReadingState; 760 791 if (reply) 761 receiveReply();792 receiveReply(); 762 793 } else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) { 763 794 // re-sending request because the socket was in ClosingState … … 842 873 } 843 874 QPointer<QObject> that = connection; 844 QString errorString = connection->d_func()->errorDetail(errorCode, socket );875 QString errorString = connection->d_func()->errorDetail(errorCode, socket); 845 876 if (send2Reply) { 846 877 if (reply) {
Note:
See TracChangeset
for help on using the changeset viewer.