CalcSizeStream css = new CalcSizeStream();
css.writeObject(response);
int responseSize = css.count();
byte[] buffer = new byte[responseSize + 4];
DataStream ds = css.hasCycles() ? new SerializeStream(buffer) : new DataStream(buffer);
ds.writeInt(responseSize);
ds.writeObject(response);
super.write(buffer, 0, buffer.length);
}