I'm trying to get the request header but I'm not able to get it. I don't get anything with request.rawHeaderList().
My actual code looks like this:
def downloadFinished(self, reply):
redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute).toUrl()
print "ERROR CODE: " + str(reply.attribute(QNetworkRequest.HttpStatusCodeAttribute).toInt())
for item in reply.rawHeaderList():
print "REPLY HEADER: " + str(item) + " === " + reply.rawHeader(str(item))
request = QNetworkRequest(redirect)
for item in request.rawHeaderList():
print "REQUEST HEADER: " + str(item) + " === " + request.rawHeader(str(item))
if not redirect.isEmpty():
print "REDIRECT: " + str(redirect)
self.reply = self.manager.get(request)
self.reply.downloadProgress.connect(self.updateDataReadProgress)
else:
self.
updateFile = QFile(self.
downloadPath) self.updateFile.write(self.reply.readAll())
self.updateFile.close()
self.reply.deleteLater()
self.manager.deleteLater()
reply.deleteLater()
def downloadFinished(self, reply):
redirect = reply.attribute(QNetworkRequest.RedirectionTargetAttribute).toUrl()
print "ERROR CODE: " + str(reply.attribute(QNetworkRequest.HttpStatusCodeAttribute).toInt())
for item in reply.rawHeaderList():
print "REPLY HEADER: " + str(item) + " === " + reply.rawHeader(str(item))
request = QNetworkRequest(redirect)
for item in request.rawHeaderList():
print "REQUEST HEADER: " + str(item) + " === " + request.rawHeader(str(item))
if not redirect.isEmpty():
print "REDIRECT: " + str(redirect)
self.reply = self.manager.get(request)
self.reply.downloadProgress.connect(self.updateDataReadProgress)
else:
self.updateFile = QFile(self.downloadPath)
self.updateFile.open(QIODevice.WriteOnly)
self.updateFile.write(self.reply.readAll())
self.updateFile.close()
self.reply.deleteLater()
self.manager.deleteLater()
reply.deleteLater()
To copy to clipboard, switch view to plain text mode
PS: Is it really that hard to make Qt act like urllib in python or wget/curl? Isn't really there something in Qt that will just work?
Bookmarks