[PyQt] QNetworkReply.header(QNetworkRequest.ContentLengthHeader) returns None

Florian Bruhin me at the-compiler.org
Wed May 18 07:07:50 BST 2016


* 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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160518/5d7c3cbf/attachment.sig>


More information about the PyQt mailing list