Skip to content

Conversation

dwisiswant0
Copy link
Member

@dwisiswant0 dwisiswant0 commented May 14, 2025

to the following DLS functions:

  • gzip_decode
  • zlib_decode, and
  • inflate

updated signatures:

-	gzip_decode(arg1 interface{}) interface{}
+	gzip_decode(data string, optionalReadLimit int) string

-	inflate(arg1 interface{}) interface{}
+	inflate(data string, optionalReadLimit int) string

-	zlib_decode(arg1 interface{}) interface{}
+	zlib_decode(data string, optionalReadLimit int) string

tests:

Test: zlib_decode(hex_decode("789cf248cdc9c907040000ffff058c01f5"))
Output: "Hello"
Test: gzip_decode(hex_decode("1f8b08000000000000fff248cdc9c907040000ffff8289d1f705000000"))
Output: "Hello"
Test: inflate(hex_decode("f248cdc9c907040000ffff"))
Output: "Hello"

Test: zlib_decode(hex_decode("789cf248cdc9c907040000ffff058c01f5"), 100)
Output: "Hello"
Test: gzip_decode(hex_decode("1f8b08000000000000fff248cdc9c907040000ffff8289d1f705000000"), 100)
Output: "Hello",
Test: inflate(hex_decode("f248cdc9c907040000ffff"), 100)
Output: "Hello"

Test: zlib_decode(hex_decode("789cf248cdc9c907040000ffff058c01f5"), 4)
Output: "Hell"
Test: gzip_decode(hex_decode("1f8b08000000000000fff248cdc9c907040000ffff8289d1f705000000"), 4)
Output: "Hell"
Test: inflate(hex_decode("f248cdc9c907040000ffff"), 4)
Output: "Hell"

closes #247

to these following DLS functions:
* gzip_decode
* zlib_decode, and
* inflate

Signed-off-by: Dwi Siswanto <[email protected]>
@HaimLC
Copy link

HaimLC commented May 14, 2025

Does io.EOF the same behavior as io.ErrUnexpectedEOF in #248 ?

@dwisiswant0
Copy link
Member Author

Does io.EOF the same behavior as io.ErrUnexpectedEOF in #248 ?

no, but because we’re using io.LimitReader, the reader will just return whatever data is available and then hit EOF. it won’t throw an error unless we switch to io.ReadFull, which expects a specific $$N$$ of data (e.g., fixed length block). if the input ends unexpectedly (corrupted or truncated or cut off), and the stream finishes before reaching that $$N$$ length, then it would return io.ErrUnexpectedEOF. see the tests. hope that clears things up!

@Mzack9999 Mzack9999 merged commit 8f050a4 into main May 14, 2025
7 checks passed
@Mzack9999 Mzack9999 deleted the dwisiswant0/refactor/adds-optionalReadLimit-params branch May 14, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support partial gzip_decode
3 participants