add all
This commit is contained in:
73
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs
vendored
Normal file
73
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class TeeInputStream
|
||||
: BaseInputStream
|
||||
{
|
||||
private readonly Stream input, tee;
|
||||
|
||||
public TeeInputStream(Stream input, Stream tee)
|
||||
{
|
||||
Debug.Assert(input.CanRead);
|
||||
Debug.Assert(tee.CanWrite);
|
||||
|
||||
this.input = input;
|
||||
this.tee = tee;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
input.Dispose();
|
||||
tee.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int i = input.Read(buffer, offset, count);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
tee.Write(buffer, offset, i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
int i = input.Read(buffer);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
tee.Write(buffer[..i]);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
int i = input.ReadByte();
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
tee.WriteByte((byte)i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
Reference in New Issue
Block a user