QHttp - how should I connect?
Hello,
I have a web page with (only) script which uses POST data. I want to write a program which would simply visit that page (without showing it / downloading / whatever) after clicking a button - so I wrote a function, which is called while clicking button:
Code:
header.setValue("Host", "www.hostname.com");
header.setContentType("application/x-www-form-urlencoded");
header.setContentLength(content.length());
http->request(header, content);
and it actually does nothing :/
Would you tell me, what I've done wrong?
If i try to save that page into a file with request(header, content, &file) I got some error - program shuts down with window like uncatched exception one...
Thainks in an advance,
Fenix Voltres
Re: QHttp - how should I connect?
I think you're using GET instead of POST in your data formatting, so use the GET method in the request as well. Anyway I'd suggest to use QNetworkAccessManager - it is much easier to use.
Re: QHttp - how should I connect?
connect to
Code:
void stateChanged ( int state )
signal to debug what http do.
read data on signal.
and try to set host.
Code:
http->setHost("www.hostname.com");
Re: QHttp - how should I connect?
Quote:
Originally Posted by
wysota
I think you're using GET instead of POST in your data formatting, so use the GET method in the request as well. Anyway I'd suggest to use
QNetworkAccessManager - it is much easier to use.
Of course - my mistake - this is GET. Anyway - this method doesn't work for me in this way...
But QNetworkAccessManager works perfectly well! Thanks much!