[Python-checkins] python/dist/src/Lib urllib2.py,1.42,1.43
Brett C.
drifty@alum.berkeley.edu
Mon, 12 May 2003 14:27:54 -0700
Skip Montanaro wrote:
> bcannon> Change Request.add_header to call string.capitalize in order to
> bcannon> normalize headers and not have any dependency on case. Closes
> bcannon> patch #649742.
>
> bcannon> ! self.headers[key.capitalize()] = val
>
> Maybe use key.title() instead?
>
> >>> "content-type".capitalize()
> 'Content-type'
> >>> "content-type".title()
> 'Content-Type'
>
So the original reason of doing 'capitalize' is because farther down in
urllib2 there is a check to see if "Content-type" is set and it is
specifically in that case. It really is a judgment call since the RFC
doesn't even keep the case consistent.
So moving to 'title' would be fine but the lines in urllib2.py that
check for the existence of 'Content-type' and 'Content-length' would
need to be changed.
-Brett