LimitedInputStream.cs 838 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System.IO;
  3. using Org.BouncyCastle.Utilities.IO;
  4. namespace Org.BouncyCastle.Asn1
  5. {
  6. internal abstract class LimitedInputStream
  7. : BaseInputStream
  8. {
  9. protected readonly Stream _in;
  10. private int _limit;
  11. internal LimitedInputStream(
  12. Stream inStream,
  13. int limit)
  14. {
  15. this._in = inStream;
  16. this._limit = limit;
  17. }
  18. internal virtual int GetRemaining()
  19. {
  20. // TODO: maybe one day this can become more accurate
  21. return _limit;
  22. }
  23. protected virtual void SetParentEofDetect(bool on)
  24. {
  25. if (_in is IndefiniteLengthInputStream)
  26. {
  27. ((IndefiniteLengthInputStream)_in).SetEofOn00(on);
  28. }
  29. }
  30. }
  31. }
  32. #endif