kennethreitz/requests — pull request #1333 by cdunklau (2013-04-28 06:46:30+00:00)
Title: Redid CaseInsensitiveDict to work correctly/sanely

Fixes #649, #1321, and #1329. Don't merge yet, I want to get
some opinions about this implementation.

There are a few things I'd like input on. I completely rewrote `CaseInsensitiveDict` because it was hard to read. Instead of subclassing `dict`, this just implements the `collections.MutableMapping` interface, storing the data in an internal dict (._store). The result is far more obvious and readable.

1. The [old version](https://github.com/kennethreitz/requests/blob/40a060cf579a7f0996c92eed578148e526d9416f/requests/structures.py#L64-L66) returns None for nonexistent keys instead of raising KeyError. Do we actually need this behavior? My version doesn't do this, but it would be fairly trivial to add.
2. Do we want header names to be titlecased? This stores keys and returns them in lowercase.

Please let me know if I can improve this at all.