Open jiehuuu opened 4 years ago
Try this:
if (e.HttpClient.Response.ContentType?.Contains("image") == true)
{
await e.GetResponseBody();
e.SetResponseBodyString("");
}
This works for me.
Thanks for your response... but not working on my side...
private async Task ProxyServer_BeforeResponse(object sender, SessionEventArgs e)
{
if (e.HttpClient.Response.ContentType?.Contains("image") == true)
{
Console.WriteLine("Image found: replacing request body");
await e.GetResponseBody();
e.SetResponseBodyString("");
Console.WriteLine("Image found: body replaced to empty");
}
}
Is this BeforeResponse handler called?
Yes, i inserted a breakpoint and hited!
can u send me ur project file?
I used the Basic example from this repository.
Hello, i tried again and worked... but some images are not blocked, like svg or base64 images
Maybe the content type is different.
base64 image is which is embedded in the html? of course it is not blocked with this method... you have to modify html body of the http response for that. It is not trivial to block every image in the webpage, since it can be drawn for example by a javascript, too...
may i close this issue?
I'm trying to block images, however, it doesn't work
I am using BeforeResponse event
Tried this:
and this