forked from pruet/DNWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientInfoPlugin.cs
49 lines (44 loc) · 1.42 KB
/
ClientInfoPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Text;
namespace DNWS
{
/// <summary>
/// Gen HTML about client info using information from request header
/// </summary>
/// <returns>HTML client info</returns>
public class ClientInfoPlugin : IPlugin
{
public HTTPResponse GetResponse(HTTPRequest request)
{
StringBuilder sb = new StringBuilder();
string[] client_endpoint = request.getPropertyByKey("RemoteEndPoint").Split(':');
string val;
sb.Append("<html><body>");
sb.Append("Client Port: ").Append(client_endpoint[1]).Append("<br />\n");
if ((val = request.getPropertyByKey("user-agent")) != null)
{
sb.Append("Browser Information: ").Append(val).Append("<br />\n");
}
if ((val = request.getPropertyByKey("accept-language")) != null)
{
sb.Append("Accept Language: ").Append(val).Append("<br />\n");
}
if ((val = request.getPropertyByKey("accept-encoding")) != null)
{
sb.Append("Accept Encoding: ").Append(val).Append("<br />\n");
}
sb.Append("</body></html>");
HTTPResponse response = new HTTPResponse(200);
response.body = Encoding.UTF8.GetBytes(sb.ToString());
return response;
}
public HTTPResponse PostProcessing(HTTPResponse response)
{
throw new NotImplementedException();
}
public void PreProcessing(HTTPRequest request)
{
throw new NotImplementedException();
}
}
}