Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make merge_kwargs case-insensitive when looking up keys.

  • Loading branch information...
commit 68edcd12b12818f773581397399ec73b055681d7 1 parent b450528
@jianli jianli authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 requests/sessions.py
View
14 requests/sessions.py
@@ -49,9 +49,19 @@ def merge_kwargs(local_kwarg, default_kwarg):
default_kwarg = from_key_val_list(default_kwarg)
local_kwarg = from_key_val_list(local_kwarg)
- # Update new values.
+ # Update new values in a case-insensitive way
+ def get_original_key(original_keys, new_key):
+ """
+ Finds the key from original_keys that case-insensitive matches new_key.
+ """
+ for original_key in original_keys:
+ if key.lower() == original_key.lower():
+ return original_key
+ return new_key
+
kwargs = default_kwarg.copy()
- kwargs.update(local_kwarg)
+ for key, value in local_kwarg.items():
+ kwargs[get_original_key(kwargs.keys(), key)] = value
# Remove keys that are set to None.
for (k, v) in local_kwarg.items():
Please sign in to comment.
Something went wrong with that request. Please try again.