HTTP Accept-Encoding

R

Roedy Green

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?
 
A

Arne Vajhøj

Roedy said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top