self.assertEqual(body, urllib2.urlopen('http://www.iana.org/domains/example/').read())
def test_response_headers(self):
- headers = urllib2.urlopen('http://www.iana.org/domains/example/').info()
with vcr.use_cassette('test/synopsis.yaml'):
- self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info())
- self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info())
+ headers = urllib2.urlopen('http://www.iana.org/domains/example/').info().items()
+ self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info().items())
if __name__ == '__main__':
-from httplib import HTTPConnection
+from httplib import HTTPConnection, HTTPMessage
from cStringIO import StringIO
from .files import save_cassette, load_cassette
from .cassette import Cassette
class VCRHTTPResponse(object):
def __init__(self, recorded_response):
self.recorded_response = recorded_response
- self.msg = recorded_response['status']['message']
self.reason = recorded_response['status']['message']
self.status = recorded_response['status']['code']
self._content = StringIO(self.recorded_response['body']['string'])
+ self.msg = HTTPMessage(StringIO(''))
+ for k, v in self.recorded_response['headers'].iteritems():
+ self.msg.addheader(k, v)
+
def read(self, chunked=False):
return self._content.read()
- def getheaders(self):
- return self.recorded_response['headers']
-
class VCRHTTPConnection(HTTPConnection):