- Code: Select all
FilterStatus IResponseFilter.Filter(Stream dataIn, out long dataInRead, Stream dataOut, out long dataOutWritten)
{
if (dataIn == null)
{
dataInRead = 0;
dataOutWritten = 0;
return FilterStatus.Done;
}
dataInRead = Math.Min(dataIn.Length, dataOut.Length);
dataOutWritten = dataInRead;
var readBytes = new byte[dataInRead];
dataIn.Read(readBytes, 0, readBytes.Length);
dataOut.Write(readBytes, 0, readBytes.Length);
if (dataInRead < dataIn.Length)
{
return FilterStatus.NeedMoreData;
}
return FilterStatus.Done;
}
So, how it's works: you read from dataIn (maximum 65536), write to dataOut(65536)
You can easily modify responses that contain <=65536 bytes, but what to do with more bytes per 1 file?
For example there is file with 65536 * 2 bytes, you need edit bytes from 65537 to 65580 in the middle, as i understood you can split your modification by half, but if you need find text/pattern first? If you wrote first 65536 bytes, then found pattern, you can't return to first chunk to modify, you already written it down.
I didn't find any other ways to modify data in google except IResponseFilter.