Fix error response
Use app settings in sample
Support for streams of unknown length