zlib Deflate to java.util.zip inflate problem

Discussion in 'Ruby' started by Dom, Apr 4, 2009.

  1. Dom

    Dom Guest

    Hello, I'm a total ruby newbie and am developing a simple app that
    tests an existing web app. Part of the request I need to post
    contains data that needs to be compressed as the web app will
    uncompress it. Currently, the java app just uses simple
    java.util.zip.Inflater to do this, and I've been able to do this from
    cocoa to java no problem. Using Ruby to craft the data and post
    request has presented a problem: when the web app gets the request,
    I'm getting exceptions from java.utl.zip Unkown Compression format I
    can't change the back end, only the ruby client side. Does anybody
    know how to properly use the ruby zlib library to deflate data such
    that java's built in classes can inflate it? Sorry if this is a basic
    question; I've googled this to death and hit nothing but dead ends.
    Here's the call that compresses:

    compressedBroadcast = Zlib::Deflate.new(nil, -
    Zlib::MAX_WBITS).deflate(binaryBroadcastData, Zlib::FINISH)

    Other than this, I'm very much enjoying the other Ruby bits. Thanks
    for any pointers.

    Dom
     
    Dom, Apr 4, 2009
    #1
    1. Advertising

  2. Dom

    Dom Guest

    Anything, anybody? Little help here...;-)

    On Apr 4, 2009, at 12:45 PM, Dom wrote:

    > Hello, I'm a total ruby newbie and am developing a simple app that
    > tests an existing web app. Part of the request I need to post
    > contains data that needs to be compressed as the web app will
    > uncompress it. Currently, the java app just uses simple
    > java.util.zip.Inflater to do this, and I've been able to do this
    > from cocoa to java no problem. Using Ruby to craft the data and post
    > request has presented a problem: when the web app gets the request,
    > I'm getting exceptions from java.utl.zip Unkown Compression format I
    > can't change the back end, only the ruby client side. Does anybody
    > know how to properly use the ruby zlib library to deflate data such
    > that java's built in classes can inflate it? Sorry if this is a
    > basic question; I've googled this to death and hit nothing but dead
    > ends. Here's the call that compresses:
    >
    > compressedBroadcast = Zlib::Deflate.new(nil, -
    > Zlib::MAX_WBITS).deflate(binaryBroadcastData, Zlib::FINISH)
    >
    > Other than this, I'm very much enjoying the other Ruby bits. Thanks
    > for any pointers.
    >
    > Dom
    >
     
    Dom, Apr 4, 2009
    #2
    1. Advertising

  3. Dom

    Dom Guest

    Thanks for the reply,

    Sorry, should have been more clear, I'm not creating files. I did
    find it, but it seems entirely focused on zip files; I'm just using
    the deflate/inflate to squeeze some data before sending it over the
    wire. Being that they're both based on zlib, you'd think that deflated
    from one would be inflatable by the other and I was hoping that
    perhaps I'm just missing a setting or not using a correct parameter to
    one of the ruby calls. But, I've pretty much tried every permutation
    and cannot get the server to inflate the data. I'd think somebody's
    doing this somewhere with success.

    On Apr 4, 2009, at 4:39 PM, Jeff Schwab wrote:

    > Dom wrote:
    >> Hello, I'm a total ruby newbie and am developing a simple app that
    >> tests an existing web app. Part of the request I need to post
    >> contains data that needs to be compressed as the web app will
    >> uncompress it. Currently, the java app just uses simple
    >> java.util.zip.Inflater to do this, and I've been able to do this
    >> from cocoa to java no problem. Using Ruby to craft the data and
    >> post request has presented a problem: when the web app gets the
    >> request, I'm getting exceptions from java.utl.zip Unkown
    >> Compression format I can't change the back end, only the ruby
    >> client side. Does anybody know how to properly use the ruby zlib
    >> library to deflate data such that java's built in classes can
    >> inflate it? Sorry if this is a basic question; I've googled this
    >> to death and hit nothing but dead ends.

    >
    > Did you find rubyzip? It doesn't seem to work under Ruby 1.9, but
    > it does have an interface supposedly modeled on java.util.zip:
    >
    > http://rubyzip.sourceforge.net/
    >
    > It's hard to believe this didn't come up when you Googled.
    >
     
    Dom, Apr 5, 2009
    #3
  4. Dom wrote:
    > Sorry, should have been more clear, I'm not creating files. I did
    > find it, but it seems entirely focused on zip files; I'm just using
    > the deflate/inflate to squeeze some data before sending it over the
    > wire. Being that they're both based on zlib, you'd think that deflated
    > from one would be inflatable by the other and I was hoping that
    > perhaps I'm just missing a setting or not using a correct parameter to
    > one of the ruby calls. But, I've pretty much tried every permutation
    > and cannot get the server to inflate the data. I'd think somebody's
    > doing this somewhere with success.


    Could it be that your java side is expecting the new zlib format?

    As could be seen in your first post, you are using -MAX_WBITS, which
    enables old (headerless? don't know what it's called) zlib format, that
    has no gzip header and no checksum. Maybe you should be using +MAX_WBITS
    (the default), which adds necessary header and checksum.
    --
    Posted via http://www.ruby-forum.com/.
     
    Alexey Borzenkov, Apr 5, 2009
    #4
  5. Dom

    Eric Hodel Guest

    On Apr 5, 2009, at 02:48, Alexey Borzenkov wrote:
    > Could it be that your java side is expecting the new zlib format?
    >
    > As could be seen in your first post, you are using -MAX_WBITS, which
    > enables old (headerless? don't know what it's called) zlib format,
    > that
    > has no gzip header and no checksum. Maybe you should be using
    > +MAX_WBITS
    > (the default), which adds necessary header and checksum.


    Agreed, you probably only want -MAX_WBITS when implementing a gzip
    stream.
     
    Eric Hodel, Apr 6, 2009
    #5
  6. Dom

    Eric Hodel Guest

    On Apr 4, 2009, at 09:45, Dom wrote:

    > compressedBroadcast = Zlib::Deflate.new(nil, -
    > Zlib::MAX_WBITS).deflate(binaryBroadcastData, Zlib::FINISH)


    I think you're asking for a gzip stream here with your -MAX_WBITS
     
    Eric Hodel, Apr 6, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    1
    Views:
    623
    Andrew Thompson
    Sep 16, 2004
  2. Replies:
    0
    Views:
    1,781
  3. HARI OM
    Replies:
    0
    Views:
    17,479
    HARI OM
    May 3, 2005
  4. Chris Malek

    Problems with Zlib::Inflate.inflate

    Chris Malek, Jan 13, 2006, in forum: Ruby
    Replies:
    3
    Views:
    466
    Chris Malek
    Jan 13, 2006
  5. Aaron Smith

    Zlib::Deflate.deflate problem

    Aaron Smith, Jun 28, 2007, in forum: Ruby
    Replies:
    1
    Views:
    121
    Aaron Smith
    Jun 28, 2007
Loading...

Share This Page