//Modify response public async Task OnResponse(object sender, SessionEventArgs e) { //read response headers var responseHeaders = e.WebSession.Response.Headers; //Try removing the HSTS header //if (e.WebSession.Response.Headers.HeaderExists("Strict-Transport-Security")) // e.WebSession.Response.Headers.RemoveHeader("Strict-Transport-Security"); //if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return; 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(); //original: e.SetResponseBody(bodyBytes); string body = await e.GetResponseBodyAsString(); //original: e.SetResponseBodyString(body); //mine //var response1 = new Response(bodyBytes); //response1.StatusCode = e.WebSession.Response.StatusCode; //response1.Headers.RemoveHeader("Strict-Transport-Security"); //response1.ContentType = e.WebSession.Response.ContentType; //response1.KeepBody = e.WebSession.Response.KeepBody; //response1.IsChunked = e.WebSession.Response.IsChunked; //response1.ContentLength = e.WebSession.Response.ContentLength; //response1.HttpVersion = e.WebSession.Response.HttpVersion; //e.Respond(response1); } } } if (e.UserData != null) { //access request from UserData property where we stored it in RequestHandler var request = (Request)e.UserData; } if (this.DomainNamesToBeWatched.Contains(e.WebSession.Request.RequestUri.Host)) { if (this.OnHttpResponseReceived != null) { var requestEvent = new HttpResponseReceivedEventArgs2( e.WebSession.Request.Url, e.WebSession.Request.IsHttps ? UrlScheme.Https : UrlScheme.Http, e.WebSession.Request.Method); if (e.WebSession.Response.Headers != null) { requestEvent.Response.Encoding = e.WebSession.Response.Encoding; IList <string> cookies = new List <string>(); foreach (var hdr in e.WebSession.Response.Headers) { requestEvent.Response.Headers.Add(new Net.HttpHeader(hdr.Name, hdr.Value)); if (hdr.Name.ToLower() == "set-cookie") { cookies.Add(hdr.Value); } } var parsedCookieCollection = CookieParser.ParseResponseCookie(cookies); foreach (var cookie in parsedCookieCollection) { requestEvent.Response.Cookies.Add(cookie); } } this.OnHttpResponseReceived(this, requestEvent); } } }