I would like to change the return type to byte[]
. This is more neat.
Stream
implements IDisposable
, so theoretically the consumer of your method would have to call your code in the using
block:
using (var receivedStream = new FileService().ServeHttpRequest(someUrl)) {
If your client definitely needs access to what Stream
provides, then by all means execute it and return it, but by returning byte[]
, you will control any unmanaged resources hidden under the covers.
source share