def test_headers_to_str_headers(self): result = [('foo', 'bar'), ('baz', 'barf')] header_dict = {'foo': b'bar', b'baz': 'barf'} ret = utils.headers_to_str_headers(header_dict) assert Counter(ret) == Counter(result) aiohttp_raw_headers = ((b'foo', b'bar'), (b'baz', b'barf')) assert Counter(utils.headers_to_str_headers(aiohttp_raw_headers)) == Counter(result)
def test_multidict_headers_to_str_headers(self): result = [('foo', 'bar'), ('baz', 'barf')] aiohttp_headers = MultiDict(foo='bar', baz=b'barf') ret = utils.headers_to_str_headers(aiohttp_headers) assert Counter(ret) == Counter(result) # This case-insensitive thingie titlecases the key aiohttp_headers = CIMultiDict(Foo='bar', Baz=b'barf') titlecase_result = [('Foo', 'bar'), ('Baz', 'barf')] ret = utils.headers_to_str_headers(aiohttp_headers) assert Counter(ret) == Counter(titlecase_result)
def __init__(self, statusline, headers, protocol='', total_len=0, is_http_request=False): if is_http_request: protocol, statusline = statusline.split(' ', 1) self.statusline = statusline self.headers = headers_to_str_headers(headers) self.protocol = protocol self.total_len = total_len self.headers_buff = None