View Full Version : Help with QHttp needed.

24th January 2006, 22:01
I’m trying to simply call a URL to handle a control of a cgi script on the web. The following function is what I’ve written, but it’s not making the call.

Here is the url that I call from Internet Explorer to achieve what I’m trying to do:

void VideoLayout::zoom(unsigned level)
QString strLevel = "zoom=";
strLevel += QString::number(level);
QByteArray ba(strLevel.toStdString().c_str());

QHttp camControl;
camControl.setHost("", 81);
camControl.post("/axis-cgi/com/ptz.cgi", ba);

I sent this to Trolltech support and here was the response i got from them.

You usually cannot just do this kind of thing with a single HTTP post. Depending on the server you will probably get an HTTP response back, pointing you to the actual URL that you should post to.
I'm afraid there is no easy solution to this - you have to implement a complete HTTP response handler to actually do these kind of things.

I'm not sure what a response handler is? I tried to catch some feedback by calling some of the following routines, which return "unknown error"

QHttpResponseHeader response = camControl.lastResponse();
int statCode = response.statusCode();
QString err = response.reasonPhrase();

Any examples or help would be wonderful. Thanks.

24th January 2006, 23:35
It means that you have to handle the response for your request and send some other request depending on the response you got. Take a look at QHttp examples in Qt docs.

25th January 2006, 02:57
The documentation is not real clear on handling a response. I'm not sure i understand what that means. The QHttpResponseHeader just gives me "unknown error"

When they handle the response are they talking about the QHttpResponseHeader or the IODevice pointer from the request routine. It seems to me that the IODevice pointer is used for a file request return.

So what is meant by response handler and what is that i'm checking for a response?

25th January 2006, 10:30
On the contrary, it is very clear about it.

Read through this, there is everything you need: http://doc.trolltech.com/4.0/network-http.html

25th January 2006, 18:33
The documentation that i refered to was the Qt Assistant. I had not seen the docs that you provided a link for. Thank you, they answered my question and it is now working for me. :)

25th January 2006, 22:09
These are the same docs you have in Assistant. I couldn't post a link to your Qt Assistant, could I? ;)