Beispiel #1
0
 public static InputStream encode(String codings, InputStream content)
     throws MessageFormatException {
   if (codings == null || codings.trim().equals("")) return content;
   String[] algos = codings.split("[ \t]*,[ \t]*");
   if (algos.length == 1 && IDENTITY.equalsIgnoreCase(algos[0])) return content;
   for (int i = 0; i < algos.length; i++) {
     if (CHUNKED.equalsIgnoreCase(algos[i])) {
       content = new ChunkingInputStream(content);
     } else if (GZIP.equalsIgnoreCase(algos[i])) {
       content = new GzipInputStream(content);
     } else if (IDENTITY.equalsIgnoreCase(algos[i])) {
       // nothing to do
     } else throw new MessageFormatException("Unsupported coding : " + algos[i]);
   }
   return content;
 }