Changeset 561 for trunk/src/network/access/qhttp.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/access/qhttp.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 65 65 #endif 66 66 67 #ifndef QT_NO_HTTP 68 67 69 QT_BEGIN_NAMESPACE 68 69 #ifndef QT_NO_HTTP70 70 71 71 class QHttpNormalRequest; … … 122 122 void _q_slotClosed(); 123 123 void _q_slotBytesWritten(qint64 numBytes); 124 #ifndef QT_NO_OPENSSL 125 void _q_slotEncryptedBytesWritten(qint64 numBytes); 126 #endif 124 127 void _q_slotDoFinished(); 125 128 void _q_slotSendRequest(); … … 135 138 void closeConn(); 136 139 void setSock(QTcpSocket *sock); 140 141 void postMoreData(); 137 142 138 143 QTcpSocket *socket; … … 514 519 /*! 515 520 \class QHttpHeader 521 \obsolete 516 522 \brief The QHttpHeader class contains header information for HTTP. 517 523 518 \ingroup io524 \ingroup network 519 525 \inmodule QtNetwork 520 526 … … 625 631 QHttpHeader::~QHttpHeader() 626 632 { 627 delete d_ptr;628 633 } 629 634 … … 951 956 952 957 /*! 953 Returns true if the header has an entry for the thespecial HTTP958 Returns true if the header has an entry for the special HTTP 954 959 header field \c content-type; otherwise returns false. 955 960 … … 1008 1013 /*! 1009 1014 \class QHttpResponseHeader 1015 \obsolete 1010 1016 \brief The QHttpResponseHeader class contains response header information for HTTP. 1011 1017 1012 \ingroup io1018 \ingroup network 1013 1019 \inmodule QtNetwork 1014 1020 … … 1153 1159 } 1154 1160 1155 /*! \ reimp1161 /*! \internal 1156 1162 */ 1157 1163 bool QHttpResponseHeader::parseLine(const QString &line, int number) … … 1212 1218 /*! 1213 1219 \class QHttpRequestHeader 1220 \obsolete 1214 1221 \brief The QHttpRequestHeader class contains request header information for HTTP. 1215 1222 1216 \ingroup io1223 \ingroup network 1217 1224 \inmodule QtNetwork 1218 1225 … … 1367 1374 } 1368 1375 1369 /*! \ reimp1376 /*! \internal 1370 1377 */ 1371 1378 bool QHttpRequestHeader::parseLine(const QString &line, int number) … … 1414 1421 /*! 1415 1422 \class QHttp 1423 \obsolete 1416 1424 \reentrant 1417 1425 1418 1426 \brief The QHttp class provides an implementation of the HTTP protocol. 1419 1427 1420 \ingroup io1428 \ingroup network 1421 1429 \inmodule QtNetwork 1422 \mainclass 1430 1423 1431 1424 1432 This class provides a direct interface to HTTP that allows you to 1425 have more control over the requests and that allows you to access1426 the response header fields.However, for new applications, it is1433 download and upload data with the HTTP protocol. 1434 However, for new applications, it is 1427 1435 recommended to use QNetworkAccessManager and QNetworkReply, as 1428 those classes possess a simpler, yet more powerful API. 1436 those classes possess a simpler, yet more powerful API 1437 and a more modern protocol implementation. 1429 1438 1430 1439 The class works asynchronously, so there are no blocking … … 1447 1456 1448 1457 To make an HTTP request you must set up suitable HTTP headers. The 1449 following example demonstrates, how to request the main HTML page 1450 from the Trolltech home page (i.e., the URL 1451 \c http://qtsoftware.com/index.html): 1458 following example demonstrates how to request the main HTML page 1459 from the Qt website (i.e., the URL \c http://qt.nokia.com/index.html): 1452 1460 1453 1461 \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 2 … … 1593 1601 This enum is used to specify the mode of connection to use: 1594 1602 1595 \value ConnectionModeHttp The connection is a regular H ttpconnection to the server1596 \value ConnectionModeHttps The H ttpsprotocol is used and the connection is encrypted using SSL.1597 1598 When using the H ttpsmode, care should be taken to connect to the sslErrors signal, and1599 handle possible S slerrors.1603 \value ConnectionModeHttp The connection is a regular HTTP connection to the server 1604 \value ConnectionModeHttps The HTTPS protocol is used and the connection is encrypted using SSL. 1605 1606 When using the HTTPS mode, care should be taken to connect to the sslErrors signal, and 1607 handle possible SSL errors. 1600 1608 1601 1609 \sa QSslSocket … … 2035 2043 2036 2044 If port is 0, it will use the default port for the \a mode used 2037 (80 for H ttp and 443 fopr Https).2045 (80 for HTTP and 443 for HTTPS). 2038 2046 2039 2047 The function does not block; instead, it returns immediately. The request … … 2162 2170 2163 2171 \a path must be a absolute path like \c /index.html or an 2164 absolute URI like \c http:// qtsoftware.com/index.html and2172 absolute URI like \c http://example.com/index.html and 2165 2173 must be encoded with either QUrl::toPercentEncoding() or 2166 2174 QUrl::encodedPath(). … … 2201 2209 2202 2210 \a path must be an absolute path like \c /index.html or an 2203 absolute URI like \c http:// qtsoftware.com/index.html and2211 absolute URI like \c http://example.com/index.html and 2204 2212 must be encoded with either QUrl::toPercentEncoding() or 2205 2213 QUrl::encodedPath(). … … 2252 2260 2253 2261 \a path must be an absolute path like \c /index.html or an 2254 absolute URI like \c http:// qtsoftware.com/index.html.2262 absolute URI like \c http://example.com/index.html. 2255 2263 2256 2264 The function does not block; instead, it returns immediately. The request … … 2657 2665 } 2658 2666 2667 #ifndef QT_NO_OPENSSL 2668 void QHttpPrivate::_q_slotEncryptedBytesWritten(qint64 written) 2669 { 2670 Q_UNUSED(written); 2671 postMoreData(); 2672 } 2673 #endif 2674 2659 2675 void QHttpPrivate::_q_slotBytesWritten(qint64 written) 2660 2676 { … … 2662 2678 bytesDone += written; 2663 2679 emit q->dataSendProgress(bytesDone, bytesTotal); 2664 2680 postMoreData(); 2681 } 2682 2683 // Send the POST data 2684 void QHttpPrivate::postMoreData() 2685 { 2665 2686 if (pendingPost) 2666 2687 return; … … 2669 2690 return; 2670 2691 2692 // the following is backported code from Qt 4.6 QNetworkAccessManager. 2693 // We also have to check the encryptedBytesToWrite() if it is an SSL socket. 2694 #ifndef QT_NO_OPENSSL 2695 QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket); 2696 // if it is really an ssl socket, check more than just bytesToWrite() 2697 if ((socket->bytesToWrite() + (sslSocket ? sslSocket->encryptedBytesToWrite() : 0)) == 0) { 2698 #else 2671 2699 if (socket->bytesToWrite() == 0) { 2700 #endif 2672 2701 int max = qMin<qint64>(4096, postDevice->size() - postDevice->pos()); 2673 2702 QByteArray arr; … … 3087 3116 q, SLOT(_q_slotBytesWritten(qint64))); 3088 3117 #ifndef QT_NO_NETWORKPROXY 3089 QObject::connect(socket, SIGNAL(proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator*)),3090 q, SIGNAL(proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator*)));3118 QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), 3119 q, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); 3091 3120 #endif 3092 3121 3093 3122 #ifndef QT_NO_OPENSSL 3094 3123 if (qobject_cast<QSslSocket *>(socket)) { 3095 QObject::connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), 3096 q, SIGNAL(sslErrors(const QList<QSslError> &))); 3124 QObject::connect(socket, SIGNAL(sslErrors(QList<QSslError>)), 3125 q, SIGNAL(sslErrors(QList<QSslError>))); 3126 QObject::connect(socket, SIGNAL(encryptedBytesWritten(qint64)), 3127 q, SLOT(_q_slotEncryptedBytesWritten(qint64))); 3097 3128 } 3098 3129 #endif
Note:
See TracChangeset
for help on using the changeset viewer.