123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using CefSharp;
- using System;
- using System.Collections.Generic;
- using System.IO;
- namespace UAS_Web.tool
- {
- class MessageFilter : IResponseFilter
- {
- public event Action<byte[]> NotifyData;
- private int contentLength = 0;
- public List<byte> dataAll = new List<byte>();
- public void SetContentLength(int contentLength)
- {
- this.contentLength = contentLength;
- }
- public void Dispose()
- {
- }
- public FilterStatus Filter(Stream dataIn, out long dataInRead, Stream dataOut, out long dataOutWritten)
- {
- try
- {
- if (dataIn == null || dataIn.Length == 0)
- {
- dataInRead = 0;
- dataOutWritten = 0;
- return FilterStatus.Done;
- }
- dataInRead = dataIn.Length;
- dataOutWritten = Math.Min(dataInRead, dataOut.Length);
- dataIn.CopyTo(dataOut);
- dataIn.Seek(0, SeekOrigin.Begin);
- byte[] bs = new byte[dataIn.Length];
- dataIn.Read(bs, 0, bs.Length);
- dataAll.AddRange(bs);
- dataInRead = dataIn.Length;
- dataOutWritten = dataIn.Length;
- return FilterStatus.NeedMoreData;
- }
- catch (Exception )
- {
- dataInRead = dataIn.Length;
- dataOutWritten = dataIn.Length;
- return FilterStatus.Done;
- }
- }
- public bool InitFilter()
- {
- return true;
- }
- }
- }
|