@@ -25,12 +25,11 @@ public class HttpProcessor : IDisposable
25
25
private const int BufSize = 4096 ;
26
26
private readonly HttpServer _srv ;
27
27
private Stream _inputStream ;
28
- public Hashtable HttpHeaders = new Hashtable ( ) ;
29
- public string HttpMethod ;
28
+ private readonly Hashtable _httpHeaders = new Hashtable ( ) ;
29
+ private string _httpMethod ;
30
30
public string HttpProtocolVersionstring ;
31
31
public string HttpUrl ;
32
32
public StreamWriter OutputStream ;
33
- private bool _isActive = true ;
34
33
35
34
public HttpProcessor ( HttpServer srv )
36
35
{
@@ -61,16 +60,16 @@ public void Process(TcpClient socket)
61
60
ParseRequest ( requestLines . First ( ) ) ;
62
61
ReadHeaders ( requestLines . Skip ( 1 ) ) ;
63
62
64
- if ( HttpMethod . Equals ( "GET" ) )
63
+ if ( _httpMethod . Equals ( "GET" ) )
65
64
{
66
65
HandleGetRequest ( ) ;
67
66
}
68
- else if ( HttpMethod . Equals ( "POST" ) )
67
+ else if ( _httpMethod . Equals ( "POST" ) )
69
68
{
70
69
HandlePostRequest ( ) ;
71
70
}
72
71
}
73
- catch ( Exception ex )
72
+ catch ( Exception )
74
73
{
75
74
WriteFailure ( ) ;
76
75
}
@@ -86,7 +85,7 @@ public void ParseRequest(string request)
86
85
{
87
86
throw new Exception ( "Invalid HTTP request line" ) ;
88
87
}
89
- HttpMethod = tokens [ 0 ] . ToUpper ( ) ;
88
+ _httpMethod = tokens [ 0 ] . ToUpper ( ) ;
90
89
HttpUrl = tokens [ 1 ] ;
91
90
}
92
91
@@ -112,7 +111,7 @@ public void ReadHeaders(IEnumerable<string> requestLines)
112
111
}
113
112
114
113
string value = line . Substring ( pos , line . Length - pos ) ;
115
- HttpHeaders [ name ] = value ;
114
+ _httpHeaders [ name ] = value ;
116
115
}
117
116
}
118
117
@@ -130,9 +129,9 @@ public void HandlePostRequest()
130
129
// length, because otherwise he won't know when he's seen it all!
131
130
132
131
MemoryStream ms = new MemoryStream ( ) ;
133
- if ( HttpHeaders . ContainsKey ( "Content-Length" ) )
132
+ if ( _httpHeaders . ContainsKey ( "Content-Length" ) )
134
133
{
135
- var contentLen = Convert . ToInt32 ( HttpHeaders [ "Content-Length" ] ) ;
134
+ var contentLen = Convert . ToInt32 ( _httpHeaders [ "Content-Length" ] ) ;
136
135
if ( contentLen > MaxPostSize )
137
136
{
138
137
throw new Exception ( $ "POST Content-Length({ contentLen } ) too big for this simple server") ;
@@ -175,7 +174,7 @@ public void WriteFailure()
175
174
176
175
public void Dispose ( )
177
176
{
178
- _isActive = false ;
177
+
179
178
}
180
179
}
181
180
0 commit comments