// Check the headers for gzip Content-Encoding
String encoding = conn.getHeaderField("Content-Encoding");
if( encoding != null && encoding.indexOf("gzip") >= 0 )
is = new GZIPInputStream(is);
ObjectInputStream ois = new ObjectInputStream(is);
MarshalledValue mv = (MarshalledValue) ois.readObject();
// A hack for jsse connection pooling (see patch ).
ois.read();
ois.close();
oos.close();
// If the encoded value is an exception throw it
Object value = mv.get();
if( value instanceof Exception )
{
throw (Exception) value;
}