mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Use OrderedDict from .compat module
This commit is contained in:
@@ -10,6 +10,8 @@ Data structures that power Requests.
|
||||
|
||||
import collections
|
||||
|
||||
from .compat import OrderedDict
|
||||
|
||||
|
||||
class CaseInsensitiveDict(collections.MutableMapping):
|
||||
"""
|
||||
@@ -40,7 +42,7 @@ class CaseInsensitiveDict(collections.MutableMapping):
|
||||
|
||||
"""
|
||||
def __init__(self, data=None, **kwargs):
|
||||
self._store = collections.OrderedDict()
|
||||
self._store = OrderedDict()
|
||||
if data is None:
|
||||
data = {}
|
||||
self.update(data, **kwargs)
|
||||
|
||||
@@ -318,11 +318,11 @@ class TestRequests:
|
||||
def test_headers_preserve_order(self, httpbin):
|
||||
"""Preserve order when headers provided as OrderedDict."""
|
||||
ses = requests.Session()
|
||||
ses.headers = collections.OrderedDict()
|
||||
ses.headers = OrderedDict()
|
||||
ses.headers['Accept-Encoding'] = 'identity'
|
||||
ses.headers['First'] = '1'
|
||||
ses.headers['Second'] = '2'
|
||||
headers = collections.OrderedDict([('Third', '3'), ('Fourth', '4')])
|
||||
headers = OrderedDict([('Third', '3'), ('Fourth', '4')])
|
||||
headers['Fifth'] = '5'
|
||||
headers['Second'] = '222'
|
||||
req = requests.Request('GET', httpbin('get'), headers = headers)
|
||||
|
||||
Reference in New Issue
Block a user