diff --git a/Titanium.Web.Proxy/RequestHandler.cs b/Titanium.Web.Proxy/RequestHandler.cs index 7c5e5053d..1dc049a0b 100644 --- a/Titanium.Web.Proxy/RequestHandler.cs +++ b/Titanium.Web.Proxy/RequestHandler.cs @@ -132,7 +132,7 @@ private static void HandleClient(TransparentProxyEndPoint endPoint, TcpClient tc //if(endPoint.UseServerNameIndication) //{ // //implement in future once SNI supported by SSL stream - // certificate = CertManager.CreateCertificate(endPoint.GenericCertificateName); + // certificate = CertManager.CreateCertificate(hostName); //} //else certificate = CertManager.CreateCertificate(endPoint.GenericCertificateName); @@ -207,7 +207,6 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S version = new Version(1, 0); } - args.ProxySession.Request.RequestHeaders = new List(); string tmpLine; @@ -217,13 +216,9 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S args.ProxySession.Request.RequestHeaders.Add(new HttpHeader(header[0], header[1])); } - - var httpRemoteUri = new Uri(!IsHttps ? httpCmdSplit[1] : (string.Concat("https://", args.ProxySession.Request.Host, httpCmdSplit[1]))); args.IsHttps = IsHttps; - - args.ProxySession.Request.RequestUri = httpRemoteUri; args.ProxySession.Request.Method = httpMethod; @@ -249,24 +244,8 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S lastRequestHostName = args.ProxySession.Request.RequestUri.Host; args.ProxySession.Request.Host = args.ProxySession.Request.RequestUri.Host; - args.ProxySession.SetConnection(connection); - args.ProxySession.SendRequest(); - - if (Enable100ContinueBehaviour) - if (args.ProxySession.Request.Is100Continue) - { - WriteResponseStatus(args.ProxySession.Response.HttpVersion, "100", - "Continue", args.Client.ClientStreamWriter); - args.Client.ClientStreamWriter.WriteLine(); - } - else if (args.ProxySession.Request.ExpectationFailed) - { - WriteResponseStatus(args.ProxySession.Response.HttpVersion, "417", - "Expectation Failed", args.Client.ClientStreamWriter); - args.Client.ClientStreamWriter.WriteLine(); - } - + //If requested interception if (BeforeRequest != null) { @@ -275,12 +254,37 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S args.ProxySession.Request.RequestLocked = true; + if (args.ProxySession.Request.ExpectContinue) + { + args.ProxySession.SetConnection(connection); + args.ProxySession.SendRequest(); + } + + if (Enable100ContinueBehaviour) + if (args.ProxySession.Request.Is100Continue) + { + WriteResponseStatus(args.ProxySession.Response.HttpVersion, "100", + "Continue", args.Client.ClientStreamWriter); + args.Client.ClientStreamWriter.WriteLine(); + } + else if (args.ProxySession.Request.ExpectationFailed) + { + WriteResponseStatus(args.ProxySession.Response.HttpVersion, "417", + "Expectation Failed", args.Client.ClientStreamWriter); + args.Client.ClientStreamWriter.WriteLine(); + } + if (args.ProxySession.Request.CancelRequest) { Dispose(client, clientStream, clientStreamReader, clientStreamWriter, args); break; } + if (!args.ProxySession.Request.ExpectContinue) + { + args.ProxySession.SetConnection(connection); + args.ProxySession.SendRequest(); + } //If request was modified by user if (args.ProxySession.Request.RequestBodyRead)