123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
- using System;
- using System.IO;
- using Org.BouncyCastle.Utilities.Zlib;
- namespace Org.BouncyCastle.Crypto.Tls
- {
- public class TlsDeflateCompression : TlsCompression
- {
- public const int LEVEL_NONE = JZlib.Z_NO_COMPRESSION;
- public const int LEVEL_FASTEST = JZlib.Z_BEST_SPEED;
- public const int LEVEL_SMALLEST = JZlib.Z_BEST_COMPRESSION;
- public const int LEVEL_DEFAULT = JZlib.Z_DEFAULT_COMPRESSION;
- protected readonly ZStream zIn, zOut;
- public TlsDeflateCompression()
- : this(LEVEL_DEFAULT)
- {
- }
- public TlsDeflateCompression(int level)
- {
- this.zIn = new ZStream();
- this.zIn.inflateInit();
- this.zOut = new ZStream();
- this.zOut.deflateInit(level);
- }
- public virtual Stream Compress(Stream output)
- {
- return new DeflateOutputStream(output, zOut, true);
- }
- public virtual Stream Decompress(Stream output)
- {
- return new DeflateOutputStream(output, zIn, false);
- }
- protected class DeflateOutputStream : ZOutputStream
- {
- public DeflateOutputStream(Stream output, ZStream z, bool compress)
- : base(output, z)
- {
- this.compress = compress;
-
- this.FlushMode = JZlib.Z_SYNC_FLUSH;
- }
- public override void Flush()
- {
-
-
-
-
-
- }
- }
- }
- }
- #endif
|