@@ -33,7 +33,8 @@ private static void HandleClient(TcpClient client)
33
33
34
34
if ( string . IsNullOrEmpty ( httpCmd ) )
35
35
{
36
- throw new EndOfStreamException ( ) ;
36
+ Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , null ) ;
37
+ return ;
37
38
}
38
39
39
40
//break up the line into three components (method, remote URL & Http Version)
@@ -80,11 +81,13 @@ private static void HandleClient(TcpClient client)
80
81
if ( sslStream != null )
81
82
sslStream . Dispose ( ) ;
82
83
83
- throw ;
84
+ Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , null ) ;
85
+ return ;
84
86
}
85
87
86
88
87
89
httpCmd = clientStreamReader . ReadLine ( ) ;
90
+
88
91
}
89
92
else if ( httpVerb . ToUpper ( ) == "CONNECT" )
90
93
{
@@ -121,7 +124,6 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S
121
124
var args = new SessionEventArgs ( BUFFER_SIZE ) ;
122
125
args . Client = client ;
123
126
124
-
125
127
try
126
128
{
127
129
//break up the line into three components (method, remote URL & Http Version)
@@ -227,26 +229,21 @@ private static void HandleHttpSessionRequest(TcpClient client, string httpCmd, S
227
229
228
230
HandleHttpSessionResponse ( args ) ;
229
231
232
+ //if connection is closing exit
230
233
if ( args . ResponseHeaders . Any ( x => x . Name . ToLower ( ) == "connection" && x . Value . ToLower ( ) == "close" ) )
231
234
{
232
235
Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , args ) ;
233
236
return ;
234
237
}
235
- //Now read the next request (if keep-Alive is enabled, otherwise exit this thread)
236
- //If client is pipeling the request, this will be immediately hit before response for previous request was made
237
- httpCmd = clientStreamReader . ReadLine ( ) ;
238
- //Http request body sent, now wait for next request
239
238
240
- client = args . Client ;
241
- clientStream = args . ClientStream ;
242
- clientStreamReader = args . ClientStreamReader ;
243
- args . ClientStreamWriter = clientStreamWriter ;
239
+ // read the next request
240
+ httpCmd = clientStreamReader . ReadLine ( ) ;
244
241
245
242
}
246
243
catch
247
244
{
248
245
Dispose ( client , clientStream , clientStreamReader , clientStreamWriter , args ) ;
249
- throw ;
246
+ return ;
250
247
}
251
248
}
252
249
}
0 commit comments