I'm using ChromiumFX in one of my project and it's been awesome What I'm trying to do now though is modify the response headers, for all the responses that get to the browser, and it doesn't seem to work as expected.
I can capture the response with it, it's headers, using this event: _browser.RequestHandler.GetResourceHandler += new CfxGetResourceHandlerEventHandler(ResourceHandler.GetResourceHandler);
Here's how I captured the headers, but looks like the response is readonly all the time:
public void OnResourceResponse(object sender, CfxOnResourceResponseEventArgs e)
{
Console.WriteLine(e.Response.IsReadOnly); // check if read-only
var headers = e.Response.GetHeaderMap(); // get header map
var new_headers = new List<string[]>();
// check for header
for (int i = 0; i < headers.Count - 1; i++)
{
var header = headers[i];
// ignore if our header
if (header[0].Equals("content-security-policy")) continue;
new_headers.Add(header);
}
e.Response.SetHeaderMap(new_headers); // set new headers
}
What I'm looking for is a simple example, that shows how to use the SetHeaderMap method for ChromiumFX, with whatever event, just something that allows me to set the headers before the response gets to the browser for rendering
Aucun commentaire:
Enregistrer un commentaire