@@ -217,18 +217,12 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S
217
217
args . ProxySession . Request . RequestHeaders . Add ( new HttpHeader ( header [ 0 ] , header [ 1 ] ) ) ;
218
218
}
219
219
220
- SetRequestHeaders ( args . ProxySession . Request . RequestHeaders , args . ProxySession ) ;
220
+
221
221
222
222
var httpRemoteUri = new Uri ( ! IsHttps ? httpCmdSplit [ 1 ] : ( string . Concat ( "https://" , args . ProxySession . Request . Host , httpCmdSplit [ 1 ] ) ) ) ;
223
223
args . IsHttps = IsHttps ;
224
224
225
- if ( args . ProxySession . Request . UpgradeToWebSocket )
226
- {
227
- TcpHelper . SendRaw ( clientStream , httpCmd , args . ProxySession . Request . RequestHeaders ,
228
- httpRemoteUri . Host , httpRemoteUri . Port , args . IsHttps ) ;
229
- Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , args ) ;
230
- return ;
231
- }
225
+
232
226
233
227
args . ProxySession . Request . RequestUri = httpRemoteUri ;
234
228
@@ -252,7 +246,15 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S
252
246
break ;
253
247
}
254
248
249
+ if ( args . ProxySession . Request . UpgradeToWebSocket )
250
+ {
251
+ TcpHelper . SendRaw ( clientStream , httpCmd , args . ProxySession . Request . RequestHeaders ,
252
+ httpRemoteUri . Host , httpRemoteUri . Port , args . IsHttps ) ;
253
+ Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , args ) ;
254
+ return ;
255
+ }
255
256
257
+ PrepareRequestHeaders ( args . ProxySession . Request . RequestHeaders , args . ProxySession ) ;
256
258
//construct the web request that we are going to issue on behalf of the client.
257
259
connection = connection == null ?
258
260
TcpConnectionManager . GetClient ( args . ProxySession . Request . RequestUri . Host , args . ProxySession . Request . RequestUri . Port , args . IsHttps )
@@ -314,20 +316,21 @@ private static void WriteConnectResponse(StreamWriter clientStreamWriter, string
314
316
clientStreamWriter . Flush ( ) ;
315
317
}
316
318
317
- private static void SetRequestHeaders ( List < HttpHeader > requestHeaders , HttpWebSession webRequest )
319
+ private static void PrepareRequestHeaders ( List < HttpHeader > requestHeaders , HttpWebSession webRequest )
318
320
{
319
321
for ( var i = 0 ; i < requestHeaders . Count ; i ++ )
320
322
{
321
323
switch ( requestHeaders [ i ] . Name . ToLower ( ) )
322
324
{
323
325
case "accept-encoding" :
324
326
requestHeaders [ i ] . Value = "gzip,deflate,zlib" ;
325
- break ;
326
-
327
+ break ;
328
+
327
329
default :
328
330
break ;
329
331
}
330
332
}
333
+
331
334
FixRequestProxyHeaders ( requestHeaders ) ;
332
335
webRequest . Request . RequestHeaders = requestHeaders ;
333
336
}
0 commit comments