]> khamidou — GitHub mirrors - vcrpy.git/commit
Serialize dict of lists, use dicts internally
authorKevin McCarthy <me@kevinmccarthy.org>
Sun, 4 May 2014 03:32:49 +0000 (17:32 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 4 May 2014 03:39:12 +0000 (17:39 -1000)
commit5e295e060388d216efae4807ceee86660cbc4588
tree29ff3455eadc57b34fd0c8de58230dc084d5bd0c
parent2ef5f9208a28c7da8b4c5684ac1773aa3279afc9
Serialize dict of lists, use dicts internally

There is a weird quirk in HTTP.  You can send the same header twice.
For this reason, headers are represented by a dict, with lists as the
values.  However, it appears that HTTPlib is completely incapable of
sending the same header twice.  This puts me in a weird position: I want
to be able to accurately represent HTTP headers in cassettes, but I
don't want the extra step of always having to do [0] in the general
case, i.e.  request.headers['key'][0]

In addition, some servers sometimes send the same header more than once,
and httplib *can* deal with this situation.

Futhermore, I wanted to keep the request and response cassette format as
similar as possible.

For this reason, in cassettes I keep a dict with lists as keys, but once
deserialized into VCR, I keep them as plain, naked dicts.
tests/unit/test_filters.py
tests/unit/test_request.py
vcr/request.py
vcr/stubs/__init__.py