Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 9bac69a

Browse files
committed
add more comments
1 parent 4bcd22f commit 9bac69a

File tree

6 files changed

+200
-16
lines changed

6 files changed

+200
-16
lines changed

Titanium.Web.Proxy/Http/Request.cs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,24 @@ namespace Titanium.Web.Proxy.Http
1212
/// </summary>
1313
public class Request
1414
{
15+
/// <summary>
16+
/// Request Method
17+
/// </summary>
1518
public string Method { get; set; }
19+
20+
/// <summary>
21+
/// Request HTTP Uri
22+
/// </summary>
1623
public Uri RequestUri { get; set; }
24+
25+
/// <summary>
26+
/// Request Http Version
27+
/// </summary>
1728
public Version HttpVersion { get; set; }
1829

30+
/// <summary>
31+
/// Request Http hostanem
32+
/// </summary>
1933
internal string Host
2034
{
2135
get
@@ -35,6 +49,9 @@ internal string Host
3549
}
3650
}
3751

52+
/// <summary>
53+
/// Request content encoding
54+
/// </summary>
3855
internal string ContentEncoding
3956
{
4057
get
@@ -50,6 +67,9 @@ internal string ContentEncoding
5067
}
5168
}
5269

70+
/// <summary>
71+
/// Request content-length
72+
/// </summary>
5373
public long ContentLength
5474
{
5575
get
@@ -68,7 +88,6 @@ public long ContentLength
6888
}
6989
set
7090
{
71-
7291
var header = RequestHeaders.FirstOrDefault(x => x.Name.ToLower() == "content-length");
7392

7493
if (value >= 0)
@@ -88,6 +107,9 @@ public long ContentLength
88107
}
89108
}
90109

110+
/// <summary>
111+
/// Request content-type
112+
/// </summary>
91113
public string ContentType
92114
{
93115
get
@@ -109,6 +131,9 @@ public string ContentType
109131

110132
}
111133

134+
/// <summary>
135+
/// Is request body send as chunked bytes
136+
/// </summary>
112137
public bool IsChunked
113138
{
114139
get
@@ -140,6 +165,9 @@ public bool IsChunked
140165
}
141166
}
142167

168+
/// <summary>
169+
/// Does this request has a 100-continue header?
170+
/// </summary>
143171
public bool ExpectContinue
144172
{
145173
get
@@ -150,19 +178,37 @@ public bool ExpectContinue
150178
}
151179
}
152180

181+
/// <summary>
182+
/// Request Url
183+
/// </summary>
153184
public string Url { get { return RequestUri.OriginalString; } }
154185

186+
/// <summary>
187+
/// Encoding for this request
188+
/// </summary>
155189
internal Encoding Encoding { get { return this.GetEncoding(); } }
156190
/// <summary>
157191
/// Terminates the underlying Tcp Connection to client after current request
158192
/// </summary>
159193
internal bool CancelRequest { get; set; }
160194

195+
/// <summary>
196+
/// Request body as byte array
197+
/// </summary>
161198
internal byte[] RequestBody { get; set; }
199+
200+
/// <summary>
201+
/// request body as string
202+
/// </summary>
162203
internal string RequestBodyString { get; set; }
204+
205+
163206
internal bool RequestBodyRead { get; set; }
164207
internal bool RequestLocked { get; set; }
165208

209+
/// <summary>
210+
/// Does this request has an upgrade to websocket header?
211+
/// </summary>
166212
internal bool UpgradeToWebSocket
167213
{
168214
get
@@ -179,8 +225,19 @@ internal bool UpgradeToWebSocket
179225
}
180226
}
181227

228+
/// <summary>
229+
/// Request heade collection
230+
/// </summary>
182231
public List<HttpHeader> RequestHeaders { get; set; }
232+
233+
/// <summary>
234+
/// Does server responsed positively for 100 continue request
235+
/// </summary>
183236
public bool Is100Continue { get; internal set; }
237+
238+
/// <summary>
239+
/// Server responsed negatively for the request for 100 continue
240+
/// </summary>
184241
public bool ExpectationFailed { get; internal set; }
185242

186243
public Request()

Titanium.Web.Proxy/Http/Response.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class Response
1818

1919
internal Encoding Encoding { get { return this.GetResponseCharacterEncoding(); } }
2020

21-
21+
/// <summary>
22+
/// Content encoding for this response
23+
/// </summary>
2224
internal string ContentEncoding
2325
{
2426
get
@@ -35,6 +37,10 @@ internal string ContentEncoding
3537
}
3638

3739
internal Version HttpVersion { get; set; }
40+
41+
/// <summary>
42+
/// Keep the connection alive?
43+
/// </summary>
3844
internal bool ResponseKeepAlive
3945
{
4046
get
@@ -51,6 +57,9 @@ internal bool ResponseKeepAlive
5157
}
5258
}
5359

60+
/// <summary>
61+
/// Content type of this response
62+
/// </summary>
5463
public string ContentType
5564
{
5665
get
@@ -67,6 +76,9 @@ public string ContentType
6776
}
6877
}
6978

79+
/// <summary>
80+
/// Length of response body
81+
/// </summary>
7082
internal long ContentLength
7183
{
7284
get
@@ -105,6 +117,9 @@ internal long ContentLength
105117
}
106118
}
107119

120+
/// <summary>
121+
/// Response transfer-encoding is chunked?
122+
/// </summary>
108123
internal bool IsChunked
109124
{
110125
get
@@ -143,14 +158,37 @@ internal bool IsChunked
143158
}
144159
}
145160

161+
/// <summary>
162+
/// Collection of all response headers
163+
/// </summary>
146164
public List<HttpHeader> ResponseHeaders { get; set; }
147165

166+
/// <summary>
167+
/// Response network stream
168+
/// </summary>
148169
internal Stream ResponseStream { get; set; }
170+
171+
/// <summary>
172+
/// response body contenst as byte array
173+
/// </summary>
149174
internal byte[] ResponseBody { get; set; }
175+
176+
/// <summary>
177+
/// response body as string
178+
/// </summary>
150179
internal string ResponseBodyString { get; set; }
180+
151181
internal bool ResponseBodyRead { get; set; }
152182
internal bool ResponseLocked { get; set; }
183+
184+
/// <summary>
185+
/// Is response 100-continue
186+
/// </summary>
153187
public bool Is100Continue { get; internal set; }
188+
189+
/// <summary>
190+
/// expectation failed returned by server?
191+
/// </summary>
154192
public bool ExpectationFailed { get; internal set; }
155193

156194
public Response()

Titanium.Web.Proxy/Network/TcpConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ internal static async Task<TcpConnection> GetClient(string hostname, int port, b
4444
//Get a unique string to identify this connection
4545
var key = GetConnectionKey(hostname, port, isHttps, version);
4646

47-
4847
while (true)
4948
{
5049
await connectionAccessLock.WaitAsync();
@@ -76,6 +75,7 @@ internal static async Task<TcpConnection> GetClient(string hostname, int port, b
7675

7776
}
7877

78+
7979
if (cached == null)
8080
cached = await CreateClient(hostname, port, isHttps, version);
8181

Titanium.Web.Proxy/ProxyServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private static void OnAcceptConnection(IAsyncResult asyn)
351351
}
352352
catch
353353
{
354-
//Other errors are discarded to keep the proxy running
354+
//Other errors are discarded to keep proxy running
355355
}
356356

357357
}

0 commit comments

Comments
 (0)