Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, July 2007
QHttp is not writing data to QIODevice


Message 1 in thread

I've wrote a simple code to do some tests of QHttp

#include <QHttp>
#include <QFile>
#include <QDebug>
#include <QCoreApplication>

int main(int argc, char *argv[])
{
         QCoreApplication app(argc, argv);

         QHttp http;
         QFile f("log.html");
         f.open(QIODevice::WriteOnly);
         qDebug()<<http.get("http://google.pl";, &f);
         qDebug()<<http.hasPendingRequests();
         QObject::connect(&http, SIGNAL(requestFinished(int, bool)),  
QCoreApplication::instance(), SLOT(quit()));
         return app.exec();
}

I expected that in file log.html there will be some data, but file is  
empty... Any ideas why is that? I'm using Qt 4.3.0 on Mac OS X 10.4.10

--
 [ signature omitted ] 

Message 2 in thread

Hi Kamil,

On Fri, Jul 27, 2007 at 13:07:10 +0200, Kamil Klimek wrote:
> I've wrote a simple code to do some tests of QHttp
> 
> #include <QHttp>
> #include <QFile>
> #include <QDebug>
> #include <QCoreApplication>
> 
> int main(int argc, char *argv[])
> {
>         QCoreApplication app(argc, argv);
> 
>         QHttp http;
>         QFile f("log.html");
>         f.open(QIODevice::WriteOnly);
>         qDebug()<<http.get("http://google.pl";, &f);

Quoting from http://doc.trolltech.com/4.3/qhttp.html#get:

"int QHttp::get ( const QString & path, QIODevice * to = 0 )
Sends a get request for 'path' to the server set by setHost() or as
specified in the constructor."

In other words 'path' isn't meant to contain the host. You have to use
setHost or the constructor for that.

HTH, Johannes
-- 
 [ signature omitted ] 

Message 3 in thread

> Quoting from http://doc.trolltech.com/4.3/qhttp.html#get:
>
> "int QHttp::get ( const QString & path, QIODevice * to = 0 )
> Sends a get request for 'path' to the server set by setHost() or as
> specified in the constructor."
>
> In other words 'path' isn't meant to contain the host. You have to use
> setHost or the constructor for that.

And the next line says:

"path must be an absolute path like /index.html or an absolute URI  
like http://www.trolltech.com/index.html.";

--
 [ signature omitted ]