anon.proxy
Class DecompressionProxyCallback

java.lang.Object
  extended by anon.proxy.DecompressionProxyCallback
All Implemented Interfaces:
ProxyCallback

public class DecompressionProxyCallback
extends java.lang.Object
implements ProxyCallback

This class provides functionality for inflating zlib- or gzip-compressed content. Due to http header replacement the JonDo may specify some content-encodings which a client (i.e wget) does not support. In this case the JonDo decodes the content itself using this class. To use its functionality, an object of this class must be registered in the PoxyCallback-framework.

Author:
Simon Pecher

Nested Class Summary
private static class DecompressionProxyCallback.DecompressionKit
           
 
Field Summary
(package private)  java.util.Hashtable decompressionKits
           
private static int FCOMMENT
           
private static int FEXTRA
           
private static int FHCRC
          these constants are copied from GZIPInputstream because they are declared private there.
private static int FNAME
           
private  int MAX_DECOMPRESSION_OUTPUT
           
 
Fields inherited from interface anon.proxy.ProxyCallback
STATUS_DELAY, STATUS_FINISHED, STATUS_PROCESSABLE
 
Constructor Summary
DecompressionProxyCallback()
           
 
Method Summary
 void closeRequest(AnonProxyRequest anonRequest)
           
 int handleDownstreamChunk(AnonProxyRequest anonRequest, ProxyCallbackBuffer buffer)
           
 int handleUpstreamChunk(AnonProxyRequest anonRequest, ProxyCallbackBuffer buffer)
           
private  int readGZIPHeader(byte[] data, int offset, int length)
          slightly modified version of private method GZIPInputStream.readHeader to extract the GZIP header fields.
private  int toUnsignedByte(byte nByte)
           
private  int toUnsignedShort(byte lower, byte upper)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decompressionKits

java.util.Hashtable decompressionKits

FHCRC

private static final int FHCRC
these constants are copied from GZIPInputstream because they are declared private there.

See Also:
Constant Field Values

FEXTRA

private static final int FEXTRA
See Also:
Constant Field Values

FNAME

private static final int FNAME
See Also:
Constant Field Values

FCOMMENT

private static final int FCOMMENT
See Also:
Constant Field Values

MAX_DECOMPRESSION_OUTPUT

private final int MAX_DECOMPRESSION_OUTPUT
See Also:
Constant Field Values
Constructor Detail

DecompressionProxyCallback

public DecompressionProxyCallback()
Method Detail

readGZIPHeader

private int readGZIPHeader(byte[] data,
                           int offset,
                           int length)
                    throws java.util.zip.DataFormatException
slightly modified version of private method GZIPInputStream.readHeader to extract the GZIP header fields. returns the length of the header in bytes.

Throws:
java.util.zip.DataFormatException

toUnsignedShort

private int toUnsignedShort(byte lower,
                            byte upper)

toUnsignedByte

private int toUnsignedByte(byte nByte)

closeRequest

public void closeRequest(AnonProxyRequest anonRequest)
Specified by:
closeRequest in interface ProxyCallback

handleDownstreamChunk

public int handleDownstreamChunk(AnonProxyRequest anonRequest,
                                 ProxyCallbackBuffer buffer)
                          throws ProxyCallbackNotProcessableException
Specified by:
handleDownstreamChunk in interface ProxyCallback
Throws:
ProxyCallbackNotProcessableException

handleUpstreamChunk

public int handleUpstreamChunk(AnonProxyRequest anonRequest,
                               ProxyCallbackBuffer buffer)
                        throws ProxyCallbackNotProcessableException
Specified by:
handleUpstreamChunk in interface ProxyCallback
Throws:
ProxyCallbackNotProcessableException