* Write the stream to a temporary storage and calculate the content length
* @param entity HTTPEntity
* @throws IOException if an exception occurred while writing data
*/
private void setStreamAsTempData(BasicHttpEntity entity) throws IOException {
OverflowBlob serialized = new OverflowBlob(256, 4096, "http-nio_", ".dat");
OutputStream out = serialized.getOutputStream();
try {
messageFormatter.writeTo(msgContext, format, out, true);
} finally {
out.close();
}
msgContext.setProperty(NhttpConstants.SERIALIZED_BYTES, serialized);
entity.setContentLength(serialized.getLength());
}