@@ -25,12 +25,11 @@ public class HttpProcessor : IDisposable
2525 private const int BufSize = 4096 ;
2626 private readonly HttpServer _srv ;
2727 private Stream _inputStream ;
28- public Hashtable HttpHeaders = new Hashtable ( ) ;
29- public string HttpMethod ;
28+ private readonly Hashtable _httpHeaders = new Hashtable ( ) ;
29+ private string _httpMethod ;
3030 public string HttpProtocolVersionstring ;
3131 public string HttpUrl ;
3232 public StreamWriter OutputStream ;
33- private bool _isActive = true ;
3433
3534 public HttpProcessor ( HttpServer srv )
3635 {
@@ -61,16 +60,16 @@ public void Process(TcpClient socket)
6160 ParseRequest ( requestLines . First ( ) ) ;
6261 ReadHeaders ( requestLines . Skip ( 1 ) ) ;
6362
64- if ( HttpMethod . Equals ( "GET" ) )
63+ if ( _httpMethod . Equals ( "GET" ) )
6564 {
6665 HandleGetRequest ( ) ;
6766 }
68- else if ( HttpMethod . Equals ( "POST" ) )
67+ else if ( _httpMethod . Equals ( "POST" ) )
6968 {
7069 HandlePostRequest ( ) ;
7170 }
7271 }
73- catch ( Exception ex )
72+ catch ( Exception )
7473 {
7574 WriteFailure ( ) ;
7675 }
@@ -86,7 +85,7 @@ public void ParseRequest(string request)
8685 {
8786 throw new Exception ( "Invalid HTTP request line" ) ;
8887 }
89- HttpMethod = tokens [ 0 ] . ToUpper ( ) ;
88+ _httpMethod = tokens [ 0 ] . ToUpper ( ) ;
9089 HttpUrl = tokens [ 1 ] ;
9190 }
9291
@@ -112,7 +111,7 @@ public void ReadHeaders(IEnumerable<string> requestLines)
112111 }
113112
114113 string value = line . Substring ( pos , line . Length - pos ) ;
115- HttpHeaders [ name ] = value ;
114+ _httpHeaders [ name ] = value ;
116115 }
117116 }
118117
@@ -130,9 +129,9 @@ public void HandlePostRequest()
130129 // length, because otherwise he won't know when he's seen it all!
131130
132131 MemoryStream ms = new MemoryStream ( ) ;
133- if ( HttpHeaders . ContainsKey ( "Content-Length" ) )
132+ if ( _httpHeaders . ContainsKey ( "Content-Length" ) )
134133 {
135- var contentLen = Convert . ToInt32 ( HttpHeaders [ "Content-Length" ] ) ;
134+ var contentLen = Convert . ToInt32 ( _httpHeaders [ "Content-Length" ] ) ;
136135 if ( contentLen > MaxPostSize )
137136 {
138137 throw new Exception ( $ "POST Content-Length({ contentLen } ) too big for this simple server") ;
@@ -175,7 +174,7 @@ public void WriteFailure()
175174
176175 public void Dispose ( )
177176 {
178- _isActive = false ;
177+
179178 }
180179 }
181180
0 commit comments