0
CefSharp是否可以攔截XHRHttpRequest並獲取響應正文值?如果是的話,我想知道它是如何完成的。cefsharp如何攔截xhr請求獲取響應體值?
CefSharp是否可以攔截XHRHttpRequest並獲取響應正文值?如果是的話,我想知道它是如何完成的。cefsharp如何攔截xhr請求獲取響應體值?
我創建了下面的類,這和從IRequestHandler.GetResourceResponseFilter
返回它的實例:
internal class ResponseSniffer : IResponseFilter
{
private readonly Action<Stream> _streamHandler;
public ResponseSniffer(Action<Stream> streamHandler)
{
_streamHandler = streamHandler;
}
public void Dispose()
{
}
public bool InitFilter()
{
return true;
}
public FilterStatus Filter(Stream dataIn, out long dataInRead, Stream dataOut, out long dataOutWritten)
{
if (dataIn == null)
{
dataInRead = 0;
dataOutWritten = 0;
return FilterStatus.Error;
}
dataIn.CopyTo(dataOut);
dataInRead = dataIn.Length;
dataOutWritten = dataInRead;
dataIn.Position = 0;
_streamHandler(dataIn);
return FilterStatus.Done;
}
}