DMTF/python-redfish-library

Decompression errors

lijok opened this issue · 4 comments

lijok commented

Python 3.6
Every response with Content-Encoding gzip results in the following error

>>> from redfish import redfish_client
>>> server = redfish_client('http://192.168.200.216', 'redfish_admin', 'Redfish!')
>>> server.login(auth='session')
>>> schema = server.get('/redfish/v1/SchemaStore/en/ComputerSystem.json/')
Error occur while decompressing body: can't concat str to bytes
Traceback (most recent call last):
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redfish\rest\v1.py", line 795, in _r
est_request
    restresp.text = decompressedfile.read()
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 276, in read
    return self._buffer.read(size)
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 463, in read
    if not self._read_gzip_header():
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 406, in _read_gzip_header
    magic = self._fp.read(2)
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\gzip.py", line 91, in read
    self.file.read(size-self._length+read)
TypeError: can't concat str to bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redfish\rest\v1.py", line 578, in ge
t
    headers=headers)
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redfish\rest\v1.py", line 964, in _r
est_request
    args=args, body=body, headers=headers)
  File "C:\Users\gecase\AppData\Local\Programs\Python\Python37-32\lib\site-packages\redfish\rest\v1.py", line 799, in _r
est_request
    raise DecompressResponseError()
redfish.rest.v1.DecompressResponseError

@lijok - I think I have fixed the issue. But I do not have a Redfish service that uses the gzip content-encoding type. Could you try out the fix in PR #23 (it is a small fix to src/redfish/rest/v1.py)?

The updated file is here:

https://github.com/DMTF/python-redfish-library/blob/90e56bc9c2d763b82ee5859095d087152b6c497c/src/redfish/rest/v1.py

lijok commented

Tested and confirmed to have fixed the issue
Thank you @billdodd
Closed

Great! Thanks for testing the fix.

The code in the master branch should be updated with the fix during our next tools meeting on November 29.

Reopening until the PR is merged to master so others are aware; thanks for confirming the fix!