karl added the comment: OK. I'm inclined to think that we should both remove trailing and leading spaces/tabs should be removed.
Reasons: 1. Production rules forbid them. 2. Trailing spaces 2.a Conformant servers will ignore with a 400 bad request (opportunity for another bugs?) 2.b Conformant proxies will rewrite the header by removing spaces. 3. Leading spaces are continuation lines. See below. I had completely missed that. The syntax for headers is: header-field = field-name ":" OWS field-value BWS field-name = token field-value = *( field-content / obs-fold ) field-content = *( HTAB / SP / VCHAR / obs-text ) obs-fold = CRLF ( SP / HTAB ) ; obsolete line folding ; see Section 3.2.4 obs-fold is about line folding which is basically a header that would look like: foo: bar\n blah: something which could be the equivalent of: foo: bar blah: something with "foo" the header field-name and "bar blah: something" the header field-value. which is clearly not the intent of an author doing: request.add_header('Accept', 'text/html') request.add_header(' User-Agent', 'foobar/1.0') because this would be parsed by a conformant server as Accept: text/html User-Agent: foobar/1.0 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17322> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com