@Override
public void write(byte[] b, int off, int len) throws IOException {
checkState();
Buffer buffer = new Buffer();
if (off == 0 && len == b.length) {
buffer.appendBytes(b);
} else {
buffer.appendBytes(Arrays.copyOfRange(b, off, off + len));
}
response.write(buffer);
}