This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author karlcow
Recipients karlcow, orsenthil, r.david.murray
Date 2013-03-03.23:08:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362352089.99.0.794632562373.issue17322@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-03-03 23:08:10karlcowsetrecipients: + karlcow, orsenthil, r.david.murray
2013-03-03 23:08:09karlcowsetmessageid: <1362352089.99.0.794632562373.issue17322@psf.upfronthosting.co.za>
2013-03-03 23:08:09karlcowlinkissue17322 messages
2013-03-03 23:08:09karlcowcreate