Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/access/qhttp.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    6565#endif
    6666
     67#ifndef QT_NO_HTTP
     68
    6769QT_BEGIN_NAMESPACE
    68 
    69 #ifndef QT_NO_HTTP
    7070
    7171class QHttpNormalRequest;
     
    122122    void _q_slotClosed();
    123123    void _q_slotBytesWritten(qint64 numBytes);
     124#ifndef QT_NO_OPENSSL
     125    void _q_slotEncryptedBytesWritten(qint64 numBytes);
     126#endif
    124127    void _q_slotDoFinished();
    125128    void _q_slotSendRequest();
     
    135138    void closeConn();
    136139    void setSock(QTcpSocket *sock);
     140
     141    void postMoreData();
    137142
    138143    QTcpSocket *socket;
     
    514519/*!
    515520    \class QHttpHeader
     521    \obsolete
    516522    \brief The QHttpHeader class contains header information for HTTP.
    517523
    518     \ingroup io
     524    \ingroup network
    519525    \inmodule QtNetwork
    520526
     
    625631QHttpHeader::~QHttpHeader()
    626632{
    627     delete d_ptr;
    628633}
    629634
     
    951956
    952957/*!
    953     Returns true if the header has an entry for the the special HTTP
     958    Returns true if the header has an entry for the special HTTP
    954959    header field \c content-type; otherwise returns false.
    955960
     
    10081013/*!
    10091014    \class QHttpResponseHeader
     1015    \obsolete
    10101016    \brief The QHttpResponseHeader class contains response header information for HTTP.
    10111017
    1012     \ingroup io
     1018    \ingroup network
    10131019    \inmodule QtNetwork
    10141020
     
    11531159}
    11541160
    1155 /*! \reimp
     1161/*! \internal
    11561162*/
    11571163bool QHttpResponseHeader::parseLine(const QString &line, int number)
     
    12121218/*!
    12131219    \class QHttpRequestHeader
     1220    \obsolete
    12141221    \brief The QHttpRequestHeader class contains request header information for HTTP.
    12151222
    1216     \ingroup io
     1223    \ingroup network
    12171224    \inmodule QtNetwork
    12181225
     
    13671374}
    13681375
    1369 /*! \reimp
     1376/*! \internal
    13701377*/
    13711378bool QHttpRequestHeader::parseLine(const QString &line, int number)
     
    14141421/*!
    14151422    \class QHttp
     1423    \obsolete
    14161424    \reentrant
    14171425
    14181426    \brief The QHttp class provides an implementation of the HTTP protocol.
    14191427
    1420     \ingroup io
     1428    \ingroup network
    14211429    \inmodule QtNetwork
    1422     \mainclass
     1430
    14231431
    14241432    This class provides a direct interface to HTTP that allows you to
    1425     have more control over the requests and that allows you to access
    1426     the response header fields. However, for new applications, it is
     1433    download and upload data with the HTTP protocol.
     1434    However, for new applications, it is
    14271435    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.
    14291438
    14301439    The class works asynchronously, so there are no blocking
     
    14471456
    14481457    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):
    14521460
    14531461    \snippet doc/src/snippets/code/src_network_access_qhttp.cpp 2
     
    15931601    This enum is used to specify the mode of connection to use:
    15941602
    1595     \value ConnectionModeHttp The connection is a regular Http connection to the server
    1596     \value ConnectionModeHttps The Https protocol is used and the connection is encrypted using SSL.
    1597 
    1598     When using the Https mode, care should be taken to connect to the sslErrors signal, and
    1599     handle possible Ssl errors.
     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.
    16001608
    16011609    \sa QSslSocket
     
    20352043
    20362044    If port is 0, it will use the default port for the \a mode used
    2037     (80 for Http and 443 fopr Https).
     2045    (80 for HTTP and 443 for HTTPS).
    20382046
    20392047    The function does not block; instead, it returns immediately. The request
     
    21622170
    21632171    \a path must be a absolute path like \c /index.html or an
    2164     absolute URI like \c http://qtsoftware.com/index.html and
     2172    absolute URI like \c http://example.com/index.html and
    21652173    must be encoded with either QUrl::toPercentEncoding() or
    21662174    QUrl::encodedPath().
     
    22012209
    22022210    \a path must be an absolute path like \c /index.html or an
    2203     absolute URI like \c http://qtsoftware.com/index.html and
     2211    absolute URI like \c http://example.com/index.html and
    22042212    must be encoded with either QUrl::toPercentEncoding() or
    22052213    QUrl::encodedPath().
     
    22522260
    22532261    \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.
    22552263
    22562264    The function does not block; instead, it returns immediately. The request
     
    26572665}
    26582666
     2667#ifndef QT_NO_OPENSSL
     2668void QHttpPrivate::_q_slotEncryptedBytesWritten(qint64 written)
     2669{
     2670    Q_UNUSED(written);
     2671    postMoreData();
     2672}
     2673#endif
     2674
    26592675void QHttpPrivate::_q_slotBytesWritten(qint64 written)
    26602676{
     
    26622678    bytesDone += written;
    26632679    emit q->dataSendProgress(bytesDone, bytesTotal);
    2664 
     2680    postMoreData();
     2681}
     2682
     2683// Send the POST data
     2684void QHttpPrivate::postMoreData()
     2685{
    26652686    if (pendingPost)
    26662687        return;
     
    26692690        return;
    26702691
     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
    26712699    if (socket->bytesToWrite() == 0) {
     2700#endif
    26722701        int max = qMin<qint64>(4096, postDevice->size() - postDevice->pos());
    26732702        QByteArray arr;
     
    30873116                     q, SLOT(_q_slotBytesWritten(qint64)));
    30883117#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*)));
    30913120#endif
    30923121
    30933122#ifndef QT_NO_OPENSSL
    30943123    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)));
    30973128    }
    30983129#endif
Note: See TracChangeset for help on using the changeset viewer.