Add support for reading original length of input stream