I had the same problem sometime ago.
I solved it like this:
self.connect(self.http, SIGNAL("responseHeaderReceived(const QHttpResponseHeader &)"), self.handleHeaderResponse)
[...]
def handleHeaderResponse(self, resp):
code = resp.statusCode()
if (code >= 300 and code < 400 and resp.hasKey("location")):
location
= QUrl(resp.
value("location")) self.http.setHost(location.host())
self.http.get(location.toString())
self.connect(self.http, SIGNAL("responseHeaderReceived(const QHttpResponseHeader &)"), self.handleHeaderResponse)
[...]
def handleHeaderResponse(self, resp):
code = resp.statusCode()
if (code >= 300 and code < 400 and resp.hasKey("location")):
location = QUrl(resp.value("location"))
self.http.setHost(location.host())
self.http.get(location.toString())
To copy to clipboard, switch view to plain text mode
As you can see it's copied from my PyQt4 application... In C++ it should be something like this (not tested!)
[...]
int code = resp.statusCode();
if (code >= 300 and code < 400 and resp.hasKey("location")) {
QUrl location
= QUrl(resp.
value("location"));
http.setHost(location.host());
http.get(location.toString());
}
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(handleHeaderResponse(const QHttpResponseHeader &)));
[...]
void MyClass::handleHeaderResponse(const QHttpResponseHeader &resp):
int code = resp.statusCode();
if (code >= 300 and code < 400 and resp.hasKey("location")) {
QUrl location = QUrl(resp.value("location"));
http.setHost(location.host());
http.get(location.toString());
}
To copy to clipboard, switch view to plain text mode
Hope it helps you!
Bookmarks