How to modificate response (more than 65536 bytes)

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

How to modificate response (more than 65536 bytes)

Postby qweasdzxc » Sat Jun 15, 2024 7:35 am

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.
qweasdzxc
Techie
 
Posts: 15
Joined: Tue Nov 23, 2021 3:09 pm

Re: How to modificate response (more than 65536 bytes)

Postby amaitland » Mon Jun 17, 2024 3:51 pm

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1312
Joined: Wed Jan 14, 2015 2:35 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 2 guests