2016年9月29日 星期四

[python] requests/utils.py", line 800, in check_header_validity "not %s" % (value, type(value)))


[python] requests/utils.py", line 800, in check_header_validity "not %s" % (value, type(value)))


$ pip freeze | grep requests
requests==2.11.1

requests 的 header 如果帶有 int 的 type 現在會出現這樣的 error

原因是

 this is the intention of this check. All header values must be passed as strings in Requests.

RFC states that headers are char strings

Is there a cross-reference link to the specification or RFC for prohibiting non-string values? According to RFC7230 §3.2, the BNF for header field values is:

 RFC 7230 其實是不接受 non-string 的 values 的


Utils.check_header_validity fails on integer values · Issue #3559 · kennethreitz/requests
https://github.com/kennethreitz/requests/issues/3559
check for headers containing return characters by nateprewitt · Pull Request #3366 · kennethreitz/requests
https://github.com/kennethreitz/requests/pull/3366