PDA

View Full Version : getUrl



incapacitant
21st April 2006, 12:21
I use the following code to send a request to a server :


int misc::getUrl( const QString & host, const QString & url, QHttp * pHttp, QIODevice * pDevice, const QString & referer )
{
qDebug( "getUrl host=%s url=%s", qPrintable( host ), qPrintable( url ) );
Proxy p = proxy();
if ( p.Enabled )
pHttp->setProxy( p.Host, p.Port, p.Login, p.Password );
pHttp->setHost( host );
QHttpRequestHeader header( "GET", url, 1, 1 );
header.setValue( "Host", host );
if ( !referer.isEmpty() )
header.setValue( "Referer", referer );
header.setContentLength( 0 );
return pHttp->request( header, 0, pDevice );
}



It works very well, trouble is I cannot get the status result of the request that I expect to get through pDevice. I tried pDevice->data(), pDevice.readLine but nothing comes back. The request does what it should do but it won't tell me what it did.

I assume this getUrl stuff is widespread (I got it from some friend), maybe you can tell me or hint at how I could get a status result !!

No need to say that I am NOT an intermediate user, hardly a novice...

wysota
21st April 2006, 12:27
You can use QHttp::lastResponse() to get hold of the last response object which contains the data you need.