Created
December 3, 2017 21:33
-
-
Save angelovstanton/0ebabddd78f80f507ed4ee9ace161167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task OnResponseModifyTrafficEventHandler(object sender, SessionEventArgs e) | |
{ | |
if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST") | |
{ | |
if (e.WebSession.Response.StatusCode == 200) | |
{ | |
if (e.WebSession.Response.ContentType != null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html")) | |
{ | |
byte[] bodyBytes = await e.GetResponseBody(); | |
await e.SetResponseBody(bodyBytes); | |
string body = await e.GetResponseBodyAsString(); | |
await e.SetResponseBodyString(body); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment