libo26 / feedparser

Automatically exported from code.google.com/p/feedparser
Other
0 stars 0 forks source link

http header comparisons are case sensitive #265

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If I use the a http connection to get feed data (example: 
http://rss.feedsportal.com/c/32509/f/480599/index.rss), the script stores the 
http headers of the answer and uses it to detect the charset and compression of 
the http package content. For example, it looks for a header called 
"content-encoding" to detect gzip compression. But many servers serve a header 
called "Content-Encoding". This is only one example for the problems with case 
sensitive http-headers.
I think, it's a good idea to lowercase all headers after getting the response 
and than only check lowercase headers to detect compression/encoding/etc. It 
keeps the code clean.
Do you think, this way will be usable?

Original issue reported on code.google.com by marco.ri...@gmail.com on 14 Mar 2011 at 9:35

GoogleCodeExporter commented 9 years ago
I looked at RFC 2616 section 4, which says that HTTP headers are case 
insensitive. Python 2 lowercases every header (great for comparisons), but 
Python 3 doesn't (great for accuracy). Based on RFC 2616, though, the 
comparisons need to made case-insensitively. Good call, Marco!

Original comment by kurtmckee on 17 Mar 2011 at 5:54

GoogleCodeExporter commented 9 years ago
Fixed in r570.

Original comment by kurtmckee on 28 Aug 2011 at 7:03

GoogleCodeExporter commented 9 years ago
Nice. Thank you.

Original comment by marco.ri...@gmail.com on 29 Aug 2011 at 8:21