[Qt-interest] QHttp::request fails, but QHttp::get works
Jimmy Cooksey
jcooksey at gmail.com
Thu Dec 3 18:00:02 CET 2009
Hi,
I'm trying to grab some XML using QHttp. I have to set some header
information, so I have to use the QHttp::request method.
My problem is that I'm receiving the response header, but not any
additional (content) data. My code is like this...
// Setting up and calling the request method
void Data::getXml(QUrl url)
{
mpHttp->setHost(url.host());
QHttpRequestHeader header("GET", url.path());
header.setValue("Host", url.host());
header.setValue("Content-type", "*/*");
header.setValue("User-Agent", "IP Phone");
header.setValue("Connection", "keep-alive");
header.setValue("Keep-Alive", "300");
header.setValue("Accept", "*/*");
header.setValue("Accept-Language", "en-us");
header.setValue("Accept-Charset", "*/*");
mpHttp->request(header, mpBuffer);
}
// This is called when responseHeaderReceived is emitted
void Data::gotResponseHeader(const QHttpResponseHeader & resp)
{
std::cout << "Response Header: " << resp.toString().toStdString() <<
std::endl;
}
// This is never called -- requestFinished is never emitted.
void Data::requestFinished(int id, bool error)
{
std::cout << "Request Finished: " << id << " Error: " << error << std::endl;
}
Alternatively, when I use mpHttp->get(url, mpBuffer), everything works
fine -- requestFinished is eventually called.
So I suspect my header is broken. Any tips would be greatly appreciated.
Thanks,
Jimmy
More information about the Qt-interest-old
mailing list