diff --git a/.build/default.ps1 b/.build/default.ps1 index fe8d6955b..441263257 100644 --- a/.build/default.ps1 +++ b/.build/default.ps1 @@ -23,6 +23,10 @@ if(!$Configuration) { $Configuration = "Release" } if(!$Version) { $Version = $env:APPVEYOR_BUILD_VERSION } if(!$Version) { $Version = "1.0.$BuildNumber" } +if(!$Branch) { $Branch = $env:APPVEYOR_REPO_BRANCH } +if(!$Branch) { $Branch = "local" } +if($Branch -eq "release" ) { $Version = "$Version-beta" } + Import-Module "$Here\Common" -DisableNameChecking $NuGet = Join-Path $SolutionRoot ".nuget\nuget.exe" diff --git a/README.md b/README.md index 25f2027cb..e6f6146c8 100644 --- a/README.md +++ b/README.md @@ -58,12 +58,12 @@ Sample request and response event handlers //Test On Request, intercept requests public void OnRequest(object sender, SessionEventArgs e) { - Console.WriteLine(e.RequestURL); - + Console.WriteLine(e.ProxySession.Request.RequestUrl); + //read request headers - var requestHeaders = e.RequestHeaders; + var requestHeaders = e.ProxySession.Request.RequestHeaders; - if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT") && e.RequestContentLength > 0) + if ((e.RequestMethod.ToUpper() == "POST" || e.RequestMethod.ToUpper() == "PUT")) { //Get/Set request body bytes byte[] bodyBytes = e.GetRequestBody(); @@ -78,7 +78,7 @@ Sample request and response event handlers //To cancel a request with a custom HTML content //Filter URL - if (e.RequestURL.Contains("google.com")) + if (e.ProxySession.Request.RequestUrl.Contains("google.com")) { e.Ok("
Blocked by titanium web proxy.
"); } @@ -86,10 +86,11 @@ Sample request and response event handlers public void OnResponse(object sender, SessionEventArgs e) { - //read response headers - var responseHeaders = e.ResponseHeaders; + ////read response headers + var responseHeaders = e.ProxySession.Response.ResponseHeaders; + - if (e.ResponseStatusCode == HttpStatusCode.OK) + if (e.ResponseStatusCode == "200") { if (e.ResponseContentType.Trim().ToLower().Contains("text/html")) { diff --git a/Titanium.Web.Proxy.Test/App.config b/Titanium.Web.Proxy.Test/App.config index ce3bd0ddd..c9ec1e68f 100644 --- a/Titanium.Web.Proxy.Test/App.config +++ b/Titanium.Web.Proxy.Test/App.config @@ -4,4 +4,17 @@Blocked by titanium web proxy.
"); //} @@ -73,27 +74,19 @@ public void OnRequest(object sender, SessionEventArgs e) //Insert script to read the Browser URL and send it back to proxy public void OnResponse(object sender, SessionEventArgs e) { + ////read response headers - //var responseHeaders = e.ResponseHeaders; - - - //if (e.ResponseStatusCode == HttpStatusCode.OK) + // var responseHeaders = e.ProxySession.Response.ResponseHeaders; + + //if (!e.ProxySession.Request.Hostname.Equals("medeczane.sgk.gov.tr")) return; + //if (e.RequestMethod == "GET" || e.RequestMethod == "POST") //{ - // if (e.ResponseContentType.Trim().ToLower().Contains("text/html")) + // if (e.ProxySession.Response.ResponseStatusCode == "200") // { - // //Get/Set response body bytes - // byte[] responseBodyBytes = e.GetResponseBody(); - // e.SetResponseBody(responseBodyBytes); - - // //Get response body as string - // string responseBody = e.GetResponseBodyAsString(); - - // //Modify e.ServerResponse - // Regex rex = new Regex("