It's a HTTP request sending method. When the goal website responses, httpFinished() will be called.
void HTTPClientBase:: HttpRequestGet()
{
QNetworkRequest network_request;
network_request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
network_request.setUrl(URL);
reply = network_manager.get(network_request);
connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
}
void HTTPClientBase::httpFinished()
{
// process the reply;
}
I can call HttpRequestGet() in a loop.
static HTTPClientBase myClient;
for(...)
{
myClient.setUrl(...);
myClient.HttpRequestGet();
}
Since the the request and response are async, so the loop can be done within an instant time. After several hundreds milliseconds, httpFinished() will be called successively.
I want to know httpFinished() will be called sequentially or simultaneously. In other words, if I need to concern simultaneous-programming problems, for example, writing the response datas into a single file.
The following statements indicate that the httpFinished method will not be executed more than once at the same time:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.