mirror of
https://github.com/torproject/stem.git
synced 2024-12-04 00:00:46 +00:00
Trailing newline broke descriptor downloads
I rewrote stem.descriptor.remote's download code for our asyncio migration. When retrieving server descriptors we ended with a double newline ('\n\n') which caused our parser to think that there are two descriptors, the second of which is '\n'. This in turned broke validation with... ====================================================================== FAIL: test_using_authorities ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 118, in test_using_authorities descriptors = list(query.run()) File "/home/atagar/Desktop/stem/stem/util/__init__.py", line 363, in _run_async_method return future.result() File "/home/atagar/Python-3.7.0/Lib/concurrent/futures/_base.py", line 432, in result return self.__get_result() ValueError: Descriptor must have a 'router' entry During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/require.py", line 60, in wrapped return func(self, *args, **kwargs) File "/home/atagar/Desktop/stem/test/require.py", line 75, in wrapped return func(self, *args, **kwargs) File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 120, in test_using_authorities self.fail('Unable to use %s (%s:%s, %s): %s' % (authority.nickname, authority.address, authority.dir_port, type(exc), exc)) AssertionError: Unable to use moria1 (128.31.0.39:9131, <class 'ValueError'>): Descriptor must have a 'router' entry
This commit is contained in:
parent
a65a477772
commit
1e1f3665ae
@ -1003,11 +1003,11 @@ def _http_body_and_headers(data: bytes) -> Tuple[bytes, Dict[str, str]]:
|
||||
encoding = headers.get('Content-Encoding')
|
||||
|
||||
if encoding == 'deflate':
|
||||
return stem.descriptor.Compression.GZIP.decompress(body_data), headers
|
||||
return stem.descriptor.Compression.GZIP.decompress(body_data).rstrip(), headers
|
||||
|
||||
for compression in stem.descriptor.Compression:
|
||||
if encoding == compression.encoding:
|
||||
return compression.decompress(body_data), headers
|
||||
return compression.decompress(body_data).rstrip(), headers
|
||||
|
||||
raise ValueError("'%s' is an unrecognized encoding" % encoding)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user