HI,
I am using Qt-extended4.43.
i am trying to make synchronous http connection.but its not connecting.
Can any one help me?
Here is the sample code.
bool syncPostURL( const QUrl& url, const QByteArray& data) {
///connect the requestFinished signal to our finished slot
connect(this,SIGNAL(requestFinished(int,bool)),SLOT(finished (int,bool)));
header.setContentType("application/x-www-form-urlencoded");
header.setValue("Host", url.host());
/// start the request and store the requestID
requestID = request(header,data);
/// block until the request is finished
loop.exec();
/// return the request status
return status;
}
virtual void finished ( int idx, bool err )
{
/// check to see if it's the request we made
if ( idx!=requestID )
return;
/// set status of the request
status = !err;
/// end the loop
loop.exit();
}
bool syncPostURL( const QUrl& url, const QByteArray& data) {
///connect the requestFinished signal to our finished slot
connect(this,SIGNAL(requestFinished(int,bool)),SLOT(finished (int,bool)));
QHttpRequestHeader header("POST", url.path());
header.setContentType("application/x-www-form-urlencoded");
header.setValue("Host", url.host());
/// start the request and store the requestID
requestID = request(header,data);
/// block until the request is finished
loop.exec();
/// return the request status
return status;
}
virtual void finished ( int idx, bool err )
{
/// check to see if it's the request we made
if ( idx!=requestID )
return;
/// set status of the request
status = !err;
/// end the loop
loop.exit();
}
To copy to clipboard, switch view to plain text mode
Bookmarks