. This is header is used when communicating with real service but should not be sent when responding back to caller (test). Instead we need to send
header to fix the below issue.
FAILED [100%]127.0.0.1 - - [27/Dec/2020 14:57:23] "GET /climateweb/rest/v1/country/annualavg/pr/1980/1999/fra.xml HTTP/1.1" 200 -
test/test_recorder.py:8 (test_something)
self = <urllib3.response.HTTPResponse object at 0x10c663410>
def _update_chunk_length(self):
# First, we'll figure out length of a chunk and then
# we'll try to read it from socket.
if self.chunk_left is not None:
return
line = self._fp.fp.readline()
line = line.split(b";", 1)[0]
try:
> self.chunk_left = int(line, 16)
E ValueError: invalid literal for int() with base 16: b'<list>\n'
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/urllib3/response.py:696: ValueError
During handling of the above exception, another exception occurred:
self = <urllib3.response.HTTPResponse object at 0x10c663410>
@contextmanager
def _error_catcher(self):
"""
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.
On exit, release the connection back to the pool.
"""
clean_exit = False
try:
try:
> yield
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/urllib3/response.py:436:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
except (HTTPException, SocketError) as e:
# This includes IncompleteRead.
> raise ProtocolError("Connection broken: %r" % e, e)
E urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(7 bytes read)', IncompleteRead(7 bytes read))
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/urllib3/response.py:454: ProtocolError
During handling of the above exception, another exception occurred:
def test_something():
# servirtium_site = "http://localhost:61417"
recorder.set_real_service('http://climatedataapi.worldbank.org')
recorder.set_request_header_replacements({'User-Agent': 'Servirtium-Testing'})
recorder.set_response_header_removals({'Set-Cookie: AWSALB', 'X-', "Date:"})
servirtium_daemon = threading.Thread(target=recorder.start, daemon=True)
servirtium_daemon.start()
recorder.RecorderHttpHandler.set_markdown_filename("just_testing_ignore_me")
> rsp = requests.get('http://localhost:61417/climateweb/rest/v1/country/annualavg/pr/1980/1999/fra.xml')
test_recorder.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/api.py:76: in get
return request('get', url, params=params, **kwargs)
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/api.py:61: in request
return session.request(method=method, url=url, **kwargs)
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/sessions.py:542: in request
resp = self.send(prep, **send_kwargs)
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/sessions.py:697: in send
r.content
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/models.py:831: in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def generate():
# Special case for urllib3.
if hasattr(self.raw, 'stream'):
try:
for chunk in self.raw.stream(chunk_size, decode_content=True):
yield chunk
except ProtocolError as e:
> raise ChunkedEncodingError(e)
E requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(7 bytes read)', IncompleteRead(7 bytes read))
/Users/yogeshnaik/.pyenv/versions/3.7.5/envs/servirtium-python/lib/python3.7/site-packages/requests/models.py:756: ChunkedEncodingError