I am using the Python Requests package to write a simple rest client. Here is my code -
r = requests.get(url, auth=(user, passwd), stream=True, verify=False)
print('headers: ')
pprint.pprint(r.headers)
print('status: ' + str(r.status_code))
print('text: ' + r.text)
Here is the output -
headers:
{'content-type': 'text/xml;charset=UTF-8',
'date': 'Thu, 16 May 2013 03:26:06 GMT',
'server': 'Apache-Coyote/1.1',
'set-cookie': 'JSESSIONID=779FC39...5698; Path=/; Secure; HttpOnly',
'transfer-encoding': 'chunked'}
status: 200
Traceback (most recent call last):
File "C:\...\client.py", line 617, in _readinto_chunked
chunk_left = self._read_next_chunk_size()
File "C:\...\client.py", line 562, in _read_next_chunk_size
return int(line, 16)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte
The response to that request is XML. Looks like it is chunked. Is there a special way to read chunked response? I would like to put the entire XML response in one string.