[PyQt] QNetworkReply.header(QNetworkRequest.ContentLengthHeader) returns None
redstone-cold
redstone-cold at 163.com
Thu May 19 17:20:05 BST 2016
I am not sure if this is a bug with the server or PyQt/Qt, but when I use Python urllib to make a same request , I get the correct Content-Length
在2016年05月18 14时07分, "Florian Bruhin"<me at the-compiler.org>写道:
* redstone-cold <redstone-cold at 163.com> [2016-05-18 13:35:55 +0800]:
> reply is type of QNetworkReply,
> QByteArray(b'Content-Length'), PyQt5.QtCore.QByteArray(b'0, 33259656')
> is the Content-Length pair returned by reply.rawHeaderPairs(), in such case,
> reply.header(QNetworkRequest.ContentLengthHeader) just returns None,
> I wonder is this a bug or not?
Looking at RFC 2616 (the HTTP specification):
https://tools.ietf.org/html/rfc2616#section-14.13
[...]
Content-Length = "Content-Length" ":" 1*DIGIT
An example is
Content-Length: 3495
and:
DIGIT = <any US-ASCII digit "0".."9">
The thing you're showing above (b'0, 33259656') thus is an invalid
value, so Qt is probably refusing to parse it.
In other words, whatever is sending that header is buggy.
Florian
--
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160520/40f7513a/attachment.html>
More information about the PyQt
mailing list