equal
deleted
inserted
replaced
55 #endif |
55 #endif |
56 |
56 |
57 QT_BEGIN_NAMESPACE |
57 QT_BEGIN_NAMESPACE |
58 |
58 |
59 // TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp |
59 // TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp |
|
60 |
|
61 QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel() |
|
62 : socket(0) |
|
63 , state(IdleState) |
|
64 , reply(0) |
|
65 , written(0) |
|
66 , bytesTotal(0) |
|
67 , resendCurrent(false) |
|
68 , lastStatus(0) |
|
69 , pendingEncrypt(false) |
|
70 , reconnectAttempts(2) |
|
71 , authMehtod(QAuthenticatorPrivate::None) |
|
72 , proxyAuthMehtod(QAuthenticatorPrivate::None) |
|
73 #ifndef QT_NO_OPENSSL |
|
74 , ignoreAllSslErrors(false) |
|
75 #endif |
|
76 , pipeliningSupported(PipeliningSupportUnknown) |
|
77 , connection(0) |
|
78 { |
|
79 // Inlining this function in the header leads to compiler error on |
|
80 // release-armv5, on at least timebox 9.2 and 10.1. |
|
81 } |
60 |
82 |
61 void QHttpNetworkConnectionChannel::init() |
83 void QHttpNetworkConnectionChannel::init() |
62 { |
84 { |
63 #ifndef QT_NO_OPENSSL |
85 #ifndef QT_NO_OPENSSL |
64 if (connection->d_func()->encrypt) |
86 if (connection->d_func()->encrypt) |
351 replyPrivate->removeAutoDecompressHeader(); |
373 replyPrivate->removeAutoDecompressHeader(); |
352 } else { |
374 } else { |
353 replyPrivate->autoDecompress = false; |
375 replyPrivate->autoDecompress = false; |
354 } |
376 } |
355 if (replyPrivate->statusCode == 100) { |
377 if (replyPrivate->statusCode == 100) { |
|
378 replyPrivate->clearHttpLayerInformation(); |
356 replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState; |
379 replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState; |
357 break; // ignore |
380 break; // ignore |
358 } |
381 } |
359 if (replyPrivate->shouldEmitSignals()) |
382 if (replyPrivate->shouldEmitSignals()) |
360 emit reply->headerChanged(); |
383 emit reply->headerChanged(); |
457 emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); |
480 emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); |
458 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); |
481 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); |
459 } else { |
482 } else { |
460 reconnectAttempts--; |
483 reconnectAttempts--; |
461 reply->d_func()->clear(); |
484 reply->d_func()->clear(); |
|
485 reply->d_func()->connection = connection; |
|
486 reply->d_func()->connectionChannel = this; |
462 closeAndResendCurrentRequest(); |
487 closeAndResendCurrentRequest(); |
463 } |
488 } |
464 } |
489 } |
465 |
490 |
466 bool QHttpNetworkConnectionChannel::ensureConnection() |
491 bool QHttpNetworkConnectionChannel::ensureConnection() |
677 { |
702 { |
678 for (int i = 0; i < alreadyPipelinedRequests.length(); i++) |
703 for (int i = 0; i < alreadyPipelinedRequests.length(); i++) |
679 connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i)); |
704 connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i)); |
680 alreadyPipelinedRequests.clear(); |
705 alreadyPipelinedRequests.clear(); |
681 |
706 |
682 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); |
707 // only run when the QHttpNetworkConnection is not currently being destructed, e.g. |
|
708 // this function is called from _q_disconnected which is called because |
|
709 // of ~QHttpNetworkConnectionPrivate |
|
710 if (qobject_cast<QHttpNetworkConnection*>(connection)) |
|
711 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); |
683 } |
712 } |
684 |
713 |
685 void QHttpNetworkConnectionChannel::eatWhitespace() |
714 void QHttpNetworkConnectionChannel::eatWhitespace() |
686 { |
715 { |
687 char c; |
716 char c; |
856 |
885 |
857 |
886 |
858 void QHttpNetworkConnectionChannel::_q_connected() |
887 void QHttpNetworkConnectionChannel::_q_connected() |
859 { |
888 { |
860 // improve performance since we get the request sent by the kernel ASAP |
889 // improve performance since we get the request sent by the kernel ASAP |
861 socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); |
890 //socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); |
|
891 // We have this commented out now. It did not have the effect we wanted. If we want to |
|
892 // do this properly, Qt has to combine multiple HTTP requests into one buffer |
|
893 // and send this to the kernel in one syscall and then the kernel immediately sends |
|
894 // it as one TCP packet because of TCP_NODELAY. |
|
895 // However, this code is currently not in Qt, so we rely on the kernel combining |
|
896 // the requests into one TCP packet. |
|
897 |
862 // not sure yet if it helps, but it makes sense |
898 // not sure yet if it helps, but it makes sense |
863 socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); |
899 socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); |
864 |
900 |
865 pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown; |
901 pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown; |
866 |
902 |
923 default: |
959 default: |
924 // all other errors are treated as NetworkError |
960 // all other errors are treated as NetworkError |
925 errorCode = QNetworkReply::UnknownNetworkError; |
961 errorCode = QNetworkReply::UnknownNetworkError; |
926 break; |
962 break; |
927 } |
963 } |
928 QPointer<QObject> that = connection; |
964 QPointer<QHttpNetworkConnection> that = connection; |
929 QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString()); |
965 QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString()); |
930 if (send2Reply) { |
966 if (send2Reply) { |
931 if (reply) { |
967 if (reply) { |
932 reply->d_func()->errorString = errorString; |
968 reply->d_func()->errorString = errorString; |
933 // this error matters only to this reply |
969 // this error matters only to this reply |
978 // bytes have been written to the socket. write even more of them :) |
1014 // bytes have been written to the socket. write even more of them :) |
979 if (isSocketWriting()) |
1015 if (isSocketWriting()) |
980 sendRequest(); |
1016 sendRequest(); |
981 // otherwise we do nothing |
1017 // otherwise we do nothing |
982 } |
1018 } |
983 #endif |
1019 |
|
1020 #endif |
|
1021 |
|
1022 void QHttpNetworkConnectionChannel::setConnection(QHttpNetworkConnection *c) |
|
1023 { |
|
1024 // Inlining this function in the header leads to compiler error on |
|
1025 // release-armv5, on at least timebox 9.2 and 10.1. |
|
1026 connection = c; |
|
1027 } |
984 |
1028 |
985 QT_END_NAMESPACE |
1029 QT_END_NAMESPACE |
986 |
1030 |
987 #include "moc_qhttpnetworkconnectionchannel_p.cpp" |
1031 #include "moc_qhttpnetworkconnectionchannel_p.cpp" |
988 |
1032 |