@@ -106,8 +106,11 @@ private async Task HandleClient(ExplicitProxyEndPoint endPoint, TcpClient tcpCli
106106 }
107107
108108 //write back successfull CONNECT response
109- connectArgs . WebSession . Response = ConnectResponse . CreateSuccessfullConnectResponse ( version ) ;
110- await clientStreamWriter . WriteResponseAsync ( connectArgs . WebSession . Response ) ;
109+ var response = ConnectResponse . CreateSuccessfullConnectResponse ( version ) ;
110+ response . Headers . FixProxyHeaders ( ) ;
111+ connectArgs . WebSession . Response = response ;
112+
113+ await clientStreamWriter . WriteResponseAsync ( response ) ;
111114
112115 var clientHelloInfo = await SslTools . PeekClientHello ( clientStream ) ;
113116 bool isClientHello = clientHelloInfo != null ;
@@ -401,14 +404,14 @@ private async Task HandleHttpSessionRequest(TcpClient client, CustomBufferedStre
401404 args . ProxyClient . ClientStreamWriter = clientStreamWriter ;
402405
403406 //proxy authorization check
404- if ( httpsConnectHostname == null && await CheckAuthorization ( clientStreamWriter , args ) == false )
407+ if ( ! args . IsTransparent && httpsConnectHostname == null && await CheckAuthorization ( clientStreamWriter , args ) == false )
405408 {
406409 break ;
407410 }
408411
409- PrepareRequestHeaders ( args . WebSession . Request . Headers ) ;
410412 if ( ! isTransparentEndPoint )
411413 {
414+ PrepareRequestHeaders ( args . WebSession . Request . Headers ) ;
412415 args . WebSession . Request . Host = args . WebSession . Request . RequestUri . Authority ;
413416 }
414417
@@ -447,6 +450,8 @@ private async Task HandleHttpSessionRequest(TcpClient client, CustomBufferedStre
447450 connection = await GetServerConnection ( args , false ) ;
448451 }
449452
453+ var response = args . WebSession . Response ;
454+
450455 //if upgrading to websocket then relay the requet without reading the contents
451456 if ( args . WebSession . Request . UpgradeToWebSocket )
452457 {
@@ -457,13 +462,16 @@ private async Task HandleHttpSessionRequest(TcpClient client, CustomBufferedStre
457462 string httpStatus = await connection . StreamReader . ReadLineAsync ( ) ;
458463
459464 Response . ParseResponseLine ( httpStatus , out var responseVersion , out int responseStatusCode , out string responseStatusDescription ) ;
460- args . WebSession . Response . HttpVersion = responseVersion ;
461- args . WebSession . Response . StatusCode = responseStatusCode ;
462- args . WebSession . Response . StatusDescription = responseStatusDescription ;
465+ response . HttpVersion = responseVersion ;
466+ response . StatusCode = responseStatusCode ;
467+ response . StatusDescription = responseStatusDescription ;
463468
464- await HeaderParser . ReadHeaders ( connection . StreamReader , args . WebSession . Response . Headers ) ;
469+ await HeaderParser . ReadHeaders ( connection . StreamReader , response . Headers ) ;
465470
466- await clientStreamWriter . WriteResponseAsync ( args . WebSession . Response ) ;
471+ if ( ! args . IsTransparent )
472+ {
473+ await clientStreamWriter . WriteResponseAsync ( response ) ;
474+ }
467475
468476 //If user requested call back then do it
469477 if ( BeforeResponse != null && ! args . WebSession . Response . ResponseLocked )
@@ -483,7 +491,7 @@ await TcpHelper.SendRaw(clientStream, connection.Stream, BufferSize,
483491 await HandleHttpSessionRequestInternal ( connection , args ) ;
484492
485493 //if connection is closing exit
486- if ( args . WebSession . Response . KeepAlive == false )
494+ if ( response . KeepAlive == false )
487495 {
488496 break ;
489497 }
@@ -522,7 +530,7 @@ private async Task HandleHttpSessionRequestInternal(TcpConnection connection, Se
522530 if ( request . ExpectContinue )
523531 {
524532 args . WebSession . SetConnection ( connection ) ;
525- await args . WebSession . SendRequest ( Enable100ContinueBehaviour ) ;
533+ await args . WebSession . SendRequest ( Enable100ContinueBehaviour , args . IsTransparent ) ;
526534 }
527535
528536 //If 100 continue was the response inform that to the client
@@ -546,7 +554,7 @@ private async Task HandleHttpSessionRequestInternal(TcpConnection connection, Se
546554 if ( ! request . ExpectContinue )
547555 {
548556 args . WebSession . SetConnection ( connection ) ;
549- await args . WebSession . SendRequest ( Enable100ContinueBehaviour ) ;
557+ await args . WebSession . SendRequest ( Enable100ContinueBehaviour , args . IsTransparent ) ;
550558 }
551559
552560 //check if content-length is > 0
0 commit comments