src/network/access/qnetworkaccessmanager.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
child 13 c0432d11811c
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
   105 
   105 
   106     The Network Access API is constructed around one QNetworkAccessManager
   106     The Network Access API is constructed around one QNetworkAccessManager
   107     object, which holds the common configuration and settings for the requests
   107     object, which holds the common configuration and settings for the requests
   108     it sends. It contains the proxy and cache configuration, as well as the
   108     it sends. It contains the proxy and cache configuration, as well as the
   109     signals related to such issues, and reply signals that can be used to
   109     signals related to such issues, and reply signals that can be used to
   110     monitor the progress of a network operation.
   110     monitor the progress of a network operation. One QNetworkAccessManager
       
   111     should be enough for the whole Qt application.
   111 
   112 
   112     Once a QNetworkAccessManager object has been created, the application can
   113     Once a QNetworkAccessManager object has been created, the application can
   113     use it to send requests over the network. A group of standard functions
   114     use it to send requests over the network. A group of standard functions
   114     are supplied that take a request and optional data, and each return a
   115     are supplied that take a request and optional data, and each return a
   115     QNetworkReply object. The returned object is used to obtain any data
   116     QNetworkReply object. The returned object is used to obtain any data
   116     returned in response to the corresponding request.
   117     returned in response to the corresponding request.
   117 
   118 
   118     A simple download off the network could be accomplished with:
   119     A simple download off the network could be accomplished with:
   119     \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 0
   120     \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 0
   120 
   121 
       
   122     QNetworkAccessManager has an asynchronous API.
   121     When the \tt replyFinished slot above is called, the parameter it
   123     When the \tt replyFinished slot above is called, the parameter it
   122     takes is the QNetworkReply object containing the downloaded data
   124     takes is the QNetworkReply object containing the downloaded data
   123     as well as meta-data (headers, etc.).
   125     as well as meta-data (headers, etc.).
   124 
   126 
   125     \note After the request has finished, it is the responsibility of the user
   127     \note After the request has finished, it is the responsibility of the user
   126     to delete the QNetworkReply object at an appropriate time. Do not directly
   128     to delete the QNetworkReply object at an appropriate time. Do not directly
   127     delete it inside the slot connected to finished(). You can use the
   129     delete it inside the slot connected to finished(). You can use the
   128     deleteLater() function.
   130     deleteLater() function.
       
   131 
       
   132     \note QNetworkAccessManager queues the requests it receives. The number
       
   133     of requests executed in parallel is dependent on the protocol.
       
   134     Currently, for the HTTP protocol on desktop platforms, 6 requests are
       
   135     executed in parallel for one host/port combination.
   129 
   136 
   130     A more involved example, assuming the manager is already existent,
   137     A more involved example, assuming the manager is already existent,
   131     can be:
   138     can be:
   132     \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 1
   139     \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 1
   133 
   140 
   547     }
   554     }
   548 }
   555 }
   549 
   556 
   550 /*!
   557 /*!
   551     Posts a request to obtain the network headers for \a request
   558     Posts a request to obtain the network headers for \a request
   552     and returns a new QNetworkReply object which will contain such headers
   559     and returns a new QNetworkReply object which will contain such headers.
   553 
   560 
   554     The function is named after the HTTP request associated (HEAD).
   561     The function is named after the HTTP request associated (HEAD).
   555 */
   562 */
   556 QNetworkReply *QNetworkAccessManager::head(const QNetworkRequest &request)
   563 QNetworkReply *QNetworkAccessManager::head(const QNetworkRequest &request)
   557 {
   564 {