[Qt-interest] HTTP CGI Problems

Bryce Salmi Bryce.Salmi at zoran.com
Thu Sep 17 21:53:14 CEST 2009


Thiago Macieira,
    Thank you for the suggestion. I ended up using your implementation successfully with:

QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request;
Request.setUrl(QUrl("http://192.168.1.20/something.cgi"));
QNetworkReply *reply = manager->get(request);

I will probably end up using the reply pointer to do some more stuff but overall this worked with some effort. I ended up using wireshark to trace the HTTP packets as they were sent. This is actually being used on an embedded ARM processor so I needed to make sure I was sending out packets first which took some effort. Once I was querying www.google.com I set it to my server and it worked perfectly.

Thank you everyone for the help and suggestions I really really really appreciate it.


Bryce

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Thiago Macieira
Sent: Wednesday, September 16, 2009 2:37 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] HTTP CGI Problems

Em Quarta-feira 16. Setembro 2009, às 17.37.01, Bryce Salmi escreveu:
> Qt-Interest,
> 
>      I am trying to program HTTP protocol into my Qt program.  When the
> user clicks a button I invoke Qt's HTTP commands to send a GET to an IP
> address and start a CGI script. Before posting here I searched through
> the archives but couldn't find anything that really answered my
> question. An example of my implementation of the HTTP protocol with Qt:
> 
> 
> 
> QHttp http("192.168.1.20");

Don't use QHttp, please. Use QNetworkAccessManager:

> 
> QFile file ("file");
> 
> http.setHost("192.168.1.20");
> 
> http.get("/something.cgi", &file);
> 
> http.close();

QNetworkReply *reply = manager.get("http://192.168.1.20/something.cgi");
connect(reply, SIGNAL(finished()), obj, SLOT(handleFinished()));

When handleFinished() is called, read the data with reply->read() and reply-
>readAll().

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14     San Francisco, California: Nov 2 - 4
      http://qt.nokia.com/qtdevdays2009




More information about the Qt-interest-old mailing list