internal void StartSession() { NetworkStream browserStream = browser.GetStream(); string request = GetRequest(browserStream, browser); var requestReader = new RequestReader(request); requestReader.CheckRequestType(); if (requestReader.IsConnect) { HandleConnect(browser, requestReader); } else if (requestReader.IsGet) { try { NetworkStream hostStream = new TcpClient(requestReader.Host, 80) .GetStream(); SendRequest(hostStream, request); HandleResponse(browser, hostStream); } catch (Exception hostException) { browser.Close(); } browser.Close(); } }
private void HandleConnect(TcpClient browser, RequestReader requestReader) { var tunnel = new TlsHandler(browser); tunnel.StartHandshake(requestReader.Host, requestReader.Port); }