Question
· Apr 18

Need to decompress string compressed with zlib. Can I manually add the "customized wrapper" intersystems requires for $System.Util.Decompress()

Hi,

We're getting a string sent to us by a client that was compressed using a java deflater (the zlib algorithm) and when trying to use $System.Util.Decompress() I get an "illegal value" error. I gather from other community posts that this is because the raw compressed string is missing the customized wrapper Iris automatically adds. I know this has been a longstanding issue for a while...just wanted to check if there'd been any updates to this functionality, or successful workarounds for decompressing raw zlib compressed data. Thanks in advance!

Product version: IRIS 2023.3
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2022.1 (Build 209_0_22062U ) Fri Dec 9 2022 10:20:46 EST
Discussion (9)2
Log in or sign up to continue

Here is a sample method to deflate without using file I/O and using XDEV instead.

ClassMethod UnDeflate(Compressed As %String, Output UnDeflated As %String) As %Status
{
    Set sc=$$$OK
    Try {
        ; open XDEV device
        Set dev="|XDEV|"_+$JOB
        Open dev:($ZF(-6,$$$XSLTLibrary,12):/HOSTNAME="XSLT") Use dev
        ; write compressed string
        Write Compressed
        ; flush buffers
        Write *-3
        ; change device mode to deflate and rewind
        Use dev:(:/COMPRESS="DEFLATE":/POSITION=0)
        ; read uncompressed content
        Read UnDeflated
    } Catch CatchError {
        #dim CatchError as %Exception.SystemException
        Set sc=CatchError.AsStatus()
    }
    Close dev
    Quit sc
}

I really wish that InterSystems implement the various compress/deflate/gzip functionality available in device I/O as utility methods. Without silly wrappers! 😉

Another wish, please InterSystems document XDEV device I/O.

Thank you! So we already have the deflated data sent to us from a client in an http header - we need to decompress it only (not compress it). It seems like this is not possible, but I appreciate you confirming! We're looking into pulling in a python library for the decompression. 

Agreed it would be nice for intersystems to add this for generic zlib compression/decmopression