Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, gzip decompression fails. I noticed when trying to decompress RESTful content bytes in my project that uses
gzip
forcontent-type
that the headers are not read correctly and I get a failure message of-3
.I suspected I could get around this by slicing the byte array of the raw content. I came across a comment from @FoamyGuy , whom knowingly or not, also found this bug, and had the same idea. That workaround also works in my own code.
I know there are some tests in tests/circuitpython/zlib_decompress.py, but not sure how these things are done here.
My project partner and I worked together to come up with the solution shown in this PR. The tested inputs used are the the same text input compressed each using deflate gzip, and zlib. The new code can reverse each into the original decompressed text. These are included below:
deflate: dtst.txt
b'\x0b\xc9HU(,\xcdL\xceVH*\xca/\xcfSH\xcb\xafP\xc8*\xcd-(V\xc8/K-R(\x01J\xe7$VU*\x94gd\x96\xa4*\xa4\xe4\xa7+\x18\x1a\x19\x9b\x98\x9a\x99[X\x1a(\x94d\xe6\xa6\x16\xeb\x01\x00'
gzip: gtst.txt
b'\x1f\x8b\x08\x08\x94\xaf\xead\x00\x03tst.txt\x00\x0b\xc9HU(,\xcdL\xceVH*\xca/\xcfSH\xcb\xafP\xc8*\xcd-(V\xc8/K-R(\x01J\xe7$VU*\x94gd\x96\xa4*\xa4\xe4\xa7+\x18\x1a\x19\x9b\x98\x9a\x99[X\x1a(\x94d\xe6\xa6\x16\xeb\x01\x00\xbe\x98\x07*C\x00\x00\x00'
zlib: ztst.txt
b'x\x9c\x0b\xc9HU(,\xcdL\xceVH*\xca/\xcfSH\xcb\xafP\xc8*\xcd-(V\xc8/K-R(\x01J\xe7$VU*\x94gd\x96\xa4*\xa4\xe4\xa7+\x18\x1a\x19\x9b\x98\x9a\x99[X\x1a(\x94d\xe6\xa6\x16\xeb\x01\x00.x\x16\xb8'
decompressed: tst.txt
b'The quick brown fox jumps over the lazy white dog 1234567890 times.'