HTTP Accept-Encoding

Discussion in 'Java' started by Roedy Green, Aug 3, 2008.

  1. Roedy Green

    Roedy Green Guest

    When you are writing Java code to pretend to be a browser, doing HTTP
    POSTs and GETs there are four possible Content-Encodings:

    deflate: zlib format defined in RFC 1950 plus the deflate compression
    mechanism described in RFC 1951.

    gzip, alias x-gzip: Java-style gzip RFC 1952 Lempel-Ziv coding with a
    32 bit CRC.

    compress, alias x-compress, UNIX compress

    identity means as-is, no compression. Use in the Content-Request
    header, but not the Content-Encoding header. Just leave out the
    Content-Encoding if it is identity.

    The way I have handled it as ask for identity or gzip, see what comes
    back and if necesary fire up GZIP.

    So my questions:

    1. Can Java be persuaded to do this deflating for you automatically or
    semi-automatically.

    2. does Java support deflate and compress?

    3. what are the relative merits of the three compression schemes?

    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Aug 3, 2008
    #1
    1. Advertising

  2. Roedy Green

    Arne Vajhøj Guest

    Roedy Green wrote:
    > When you are writing Java code to pretend to be a browser, doing HTTP
    > POSTs and GETs there are four possible Content-Encodings:
    >
    > deflate: zlib format defined in RFC 1950 plus the deflate compression
    > mechanism described in RFC 1951.
    >
    > gzip, alias x-gzip: Java-style gzip RFC 1952 Lempel-Ziv coding with a
    > 32 bit CRC.
    >
    > compress, alias x-compress, UNIX compress
    >
    > identity means as-is, no compression. Use in the Content-Request
    > header, but not the Content-Encoding header. Just leave out the
    > Content-Encoding if it is identity.
    >
    > The way I have handled it as ask for identity or gzip, see what comes
    > back and if necesary fire up GZIP.
    >
    > So my questions:
    >
    > 1. Can Java be persuaded to do this deflating for you automatically or
    > semi-automatically.


    Not (Http)URLConnection. I don't even think HttpClient does it.

    > 2. does Java support deflate and compress?


    Deflate is in java.util.zip !

    Compress is not in standard Java, but I will guess you can
    find an implementation somewhere.

    Don't spend too much time on it. It is not used much in HTTP context.

    > 3. what are the relative merits of the three compression schemes?


    Deflate is the basic ZIP algorithm which is of the LZ77 family. It
    is very widely used.

    GZIP is the same algorithm, but with a header and a trailer.

    Compress or LZC is an implementation of LZW which is of the LZ78
    family.

    Compress does not provide as good a compression as ZIP. The only
    advantage it has is CPU and memory usage. Not relevant in Java SE
    context on modern hardware.

    Arne
    Arne Vajhøj, Aug 3, 2008
    #2
    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. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,796
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Replies:
    0
    Views:
    267
  3. Michael Reichenbach
    Replies:
    17
    Views:
    1,320
    Zachary Turner
    Jul 19, 2007
  4. Replies:
    1
    Views:
    113
    David Vallner
    Oct 20, 2006
  5. Stefan Fischer
    Replies:
    2
    Views:
    238
    Stefan Fischer
    Feb 23, 2010
Loading...

Share This Page