LimitedInputStream.cs 933 B

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