public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] ip_port = request.getPropertyByKey("RemoteEndPoint").Split(":"); string ip_client = ip_port[0]; string port_client = ip_port[1]; sb.Append("<html><body>"); sb.Append("<p>Client IP : " + ip_client + "</p>"); sb.Append("<p>Client Port : " + port_client + "</p>"); sb.Append("<p>Browser Information : " + request.getPropertyByKey("User-Agent") + "</p>"); sb.Append("<p>Accept Language : " + request.getPropertyByKey("Accept-Language") + "</p>"); sb.Append("<p>Accept Encoding : " + request.getPropertyByKey("Accept-Encoding") + "</p>"); //tracking thread sb.Append("<p>Thread-ID: " + Thread.CurrentThread.ManagedThreadId + "</p>"); //Thread-ID sb.Append("<p>Thread-State: " + Thread.CurrentThread.ThreadState + "</p>"); //Status of this thread sb.Append("<p>#Thread:" + Process.GetCurrentProcess().Threads.Count + "</p>"); //number of this thread on this process sb.Append("<p>process-ID:" + Process.GetCurrentProcess().Id + "</p>"); //PID sb.Append("<p>process-Name:" + Process.GetCurrentProcess().ProcessName + "</p>"); //name of this process sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { StringBuilder sb = new StringBuilder(); String keep = request.getPropertyByKey("remoteendpoint"); string[] IP = keep.Split(':'); String support = request.getPropertyByKey("user-agent"); String language = request.getPropertyByKey("accept-language"); String encoding = request.getPropertyByKey("accept-encoding"); sb.Append("<html><body><h1>Client:</h1>"); sb.Append("Client IP : " + IP[0]); sb.Append("<br>Client Port: " + IP[1]); sb.Append("<br>Browser Information: " + support); sb.Append("<br>Accept Language: " + language); sb.Append("<br>Accept Encoding: " + encoding); sb.Append("</body></html>"); HTTPResponse response = null; Console.WriteLine("data"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
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 GetResponse(HTTPRequest request) { StringBuilder StringBuild = new StringBuilder(); string[] ClientEndPoint = request.getPropertyByKey("RemoteEndPoint").Split(':'); string temp; StringBuild.Append("<html><body>"); StringBuild.Append("Client IP: ").Append(ClientEndPoint[0]).Append("<br />\n"); StringBuild.Append("Client Port: ").Append(ClientEndPoint[1]).Append("<br />\n"); if((temp = request.getPropertyByKey("User-agent")) != null){ StringBuild.Append("Browser Information: ").Append(temp).Append("<br />\n"); } if((temp = request.getPropertyByKey("accept-language")) != null) { StringBuild.Append("Accept Language: ").Append(temp).Append("<br />\n"); } if((temp = request.getPropertyByKey("accept-encoding") != null){ StringBuild.Append("Accept Encoding: ").Append(temp).Append("<br />\n"); } StringBuild.Append("</body></html>"); HTTPResponse Response = new HTTPResponse(200); Response.body = Encoding.UTF8.GetBytes(sb.ToString()); return Response; }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] IP = request.getPropertyByKey("RemoteEndPoint").Split(":"); // Split IP value and Port value // request.getPropertyByKey("RemoteEndPoint"); sb.Append("<html><body><p>Client IP: " + IP[0] + "</p>"); // Show Client IP sb.Append("<p>Client Port: " + IP[1] + "</p>"); // Show Client Port sb.Append("<p>Browser Information: " + request.getPropertyByKey("User-Agent") + "</p>"); // Show browser information sb.Append("<p>Accept-Language: " + request.getPropertyByKey("Accept-Language") + "</p>"); // Show accept-charset sb.Append("<p>Accept-Encoding: " + request.getPropertyByKey("Accept-Encoding") + "</p>"); // Show accept encoding sb.Append("</body></html>"); Process thisProc = Process.GetCurrentProcess(); // Creates a new Process object and associates it with the currently active process int ProcThread = thisProc.Threads.Count; Console.WriteLine("Threads ID : " + Thread.CurrentThread.ManagedThreadId); Console.WriteLine("Threads : " + ProcThread); Console.WriteLine("PID : " + thisProc.Id); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); ThreadPool.GetAvailableThreads(out int worker, out int io); ThreadPool.GetMaxThreads(out int workerThreads, out int portThreads); string[] ip_port = request.getPropertyByKey("RemoteEndPoint").Split(':');//this file 600611030 teach me ; sb.Append("<html><body>" + "Client IP: " + ip_port[0]); sb.Append("<br>" + "Client Port: " + ip_port[1]); sb.Append("<br>" + "Browser Information: " + request.getPropertyByKey("User-Agent")); sb.Append("<br>" + "Accept Language: " + request.getPropertyByKey("Accept-Language")); sb.Append("<br>" + "Accept Encoding: " + request.getPropertyByKey("Accept-Encoding")); sb.Append("<br>" + "Thread ID: " + Thread.CurrentThread.ManagedThreadId); //I find in this web https://stackoverflow.com/questions/1679243/getting-the-thread-id-from-a-thread sb.Append("<br>" + "Thread count: " + Process.GetCurrentProcess().Threads.Count); //I get code from this web https://stackoverflow.com/questions/15381174/how-to-count-the-amount-of-concurrent-threads-in-net-application sb.Append("<br>" + "Size of thread: " + workerThreads); sb.Append("<br>" + "Available thread : " + worker); sb.Append("<br>" + "Active thread: " + (workerThreads - worker)); //https://docs.microsoft.com/en-us/dotnet/api/system.threading.threadpool?view=netframework-4.7.2 sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { String[] IPandPort = Regex.Split(request.getPropertyByKey("RemoteEndPoint"), ":"); HTTPResponse response = null; StringBuilder sb = new StringBuilder(); sb.Append("<html><body>"); sb.Append("Client IP: "); sb.Append(IPandPort[0]); sb.Append("<br><br>"); sb.Append("Client Port: "); sb.Append(IPandPort[1]); sb.Append("<br><br>"); sb.Append("Browser Information: "); sb.Append(request.getPropertyByKey("User-Agent")); sb.Append("<br><br>"); sb.Append("Accept Language: "); sb.Append(request.getPropertyByKey("Accept-Language")); sb.Append("<br><br>"); sb.Append("Accept Encoding: "); sb.Append(request.getPropertyByKey("Accept-Encoding")); sb.Append("<br><br>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] ip = request.getPropertyByKey("RemoteEndPoint").Split(':');//teach from 600611030 sb.Append("<html><body>"); sb.Append("<br>" + "Port:" + ip[1]); sb.Append("<br>" + "IP:" + ip[0]); sb.Append("<br>" + "Browser:" + request.getPropertyByKey("User-Agent")); sb.Append("<br>" + "Language:" + request.getPropertyByKey("Accept-Language")); sb.Append("<br>" + "Ecoding:" + request.getPropertyByKey("Accept-Encoding")); sb.Append("<br>" + "Thread ID: " + Thread.CurrentThread.ManagedThreadId); //from 600611030 give advice me. sb.Append("<br>" + "Amount of thread: " + Process.GetCurrentProcess().Threads.Count); ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads); ThreadPool.GetMaxThreads(out int max_workerThreads, out int max_completionPortThreads); sb.Append("<br>" + "Size of thread: " + max_workerThreads); sb.Append("<br>" + "Available thread " + workerThreads); sb.Append("<br>" + "Active thread: " + (max_workerThreads - workerThreads)); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] remoteEndpoint = request.getPropertyByKey("RemoteEndPoint").Split(':'); string ip = remoteEndpoint[0], port = remoteEndpoint[1]; sb.Append("<html><body>Client IP: " + ip + "</br></br>"); sb.Append("Client Port: " + port + "</br></br>"); sb.Append("Browser Information: " + request.getPropertyByKey("User-Agent") + "</br></br>"); sb.Append("Accept-Language: " + request.getPropertyByKey("Accept-Language") + "</br></br>"); sb.Append("Accept-Encoding: " + request.getPropertyByKey("Accept-Encoding") + "</br></br>"); sb.Append("Thread ID: " + Thread.CurrentThread.ManagedThreadId + "</br></br>"); //from https://stackoverflow.com/questions/15381174/how-to-count-the-amount-of-concurrent-threads-in-net-application sb.Append("Amount of thread: " + Process.GetCurrentProcess().Threads.Count + "</br></br>"); ThreadPool.GetAvailableThreads(out int workers, out int completion); ThreadPool.GetMaxThreads(out int max_workers, out int max_completion); sb.Append("Size of thread pool: " + max_workers + "<br /><br />"); sb.Append("Available threads in thread pool: " + workers + "<br /><br />"); sb.Append("Active threads in thread pool: " + (max_workers - workers) + "<br /><br />"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); //int ip = request.IPclient; string[] ip_port = request.getPropertyByKey("RemoteEndpoint").Split(':'); // create string array ip_port to split between ip and port request.getPropertyByKey("RemoteEndpoint"); // to call ip and port string x = request.line; //create string x to split between line //split each lines string[] lines = Regex.Split(x, "\\n"); //split :User-Agent string[] i = lines[5].Split(':'); //add some informations //create variable name th is a thread var th = Thread.CurrentThread; int ThreadsCount = 0; int worker = 0; int io = 0; ThreadPool.GetAvailableThreads(out worker, out io); ThreadsCount = Process.GetCurrentProcess().Threads.Count; sb.Append("<html><body><p>Client IP address : " + ip_port[0] + "</p>"); sb.Append("<p>Client Port : " + ip_port[1] + "</p>"); sb.Append("<p>Browser Information : " + i[1] + "</p>"); sb.Append("<p>" + lines[8] + "</p>"); sb.Append("<p>" + lines[7] + "</p>"); sb.Append("<p>Thread ID : " + th.ManagedThreadId + "</p>"); sb.Append("<p>Thread is alive : " + th.IsAlive + "</p>"); //This thread is still alive or not sb.Append("<p>Thread run on background : " + th.IsBackground + "</p>"); //This thread has run on background or not sb.Append("<p>Thread status : " + th.ThreadState + "</p>"); sb.Append("<p>Threads count: " + ThreadsCount + "</p>"); sb.Append("<p>Thread available: " + worker + "</p>"); sb.Append("<p>Asynchronous thread: " + io + "</p>"); //th.Start(); //Console.WriteLine( Thread.ResetAbort()); /*foreach (KeyValuePair<String, int> entry in statDictionary) * { * sb.Append(entry.Key + ": " + entry.Value.ToString() + "<br />"); * }*/ sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] client = Regex.Split(request.getPropertyByKey("remoteendpoint"), ":"); sb.Append("<html><body>"); sb.Append("Client IP address: " + client[0] + "<br><br>"); sb.Append("Client Port: " + client[1] + "<br><br>"); sb.Append("Browser Information: " + request.getPropertyByKey("user-agent") + "<br><br>"); sb.Append("Accept-Charset: " + request.getPropertyByKey("accept-language") + "<br><br>"); sb.Append("Accept-Encoding: " + request.getPropertyByKey("accept-encoding")); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] lines = request.getPropertyByKey("remoteendpoint").Split(":"); sb.Append("Client IP : " + lines[0] + "<br>"); sb.Append("Client Port : " + lines[1] + "<br>"); sb.Append("Browser Information : " + request.getPropertyByKey("User-Agent") + "<br>"); sb.Append("Accept Language : " + request.getPropertyByKey("Accept-Language") + "<br>"); sb.Append("Accept Encoding : " + request.getPropertyByKey("Accept-Encoding") + "<br>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] words = request.getPropertyByKey("remoteendpoint").Split(':'); sb.Append("<html><body><h1>ClientInfo:</h1>"); sb.Append("<h3>Client IP address " + words[0] + "</h3>"); sb.Append("<h3>Client Port " + words[1] + "</h3>"); sb.Append("<h3>Browser Information " + request.getPropertyByKey("user-agent") + "</h3>"); sb.Append("<h3>Accept-Language " + request.getPropertyByKey("accept-language") + "</h3>"); sb.Append("<h3>Accept-Encoding " + request.getPropertyByKey("accept-encoding") + "</h3>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) //Server response with HTTP { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] ipport = request.getPropertyByKey("RemoteEndPoint").Split(':'); sb.Append("<html><font face=\"verdana\"><style>body {background-color: lightblue;}</style><body>Client IP: " + ipport[0] + "</br></br>"); //open Tag html in application layer sb.Append("Client Port: " + ipport[1] + "</br></br>"); sb.Append("Browser Information: " + request.getPropertyByKey("User-Agent") + "</br></br>"); sb.Append("Accept Language: " + request.getPropertyByKey("Accept-Language") + "</br></br>"); sb.Append("Accept Encoding: " + request.getPropertyByKey("Accept-Encoding")); sb.Append("Thread ID: " + Thread.CurrentThread.ManagedThreadId + "</br></br>"); //From https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.getcurrentprocess?view=netframework-4.7.2 sb.Append("Thead: " + Process.GetCurrentProcess().Threads.Count); sb.Append("</body></font></html>"); //Close tag response = new HTTPResponse(200); //ACK response.body = Encoding.UTF8.GetBytes(sb.ToString()); //Encode (translate to string) return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] IpAddr = request.getPropertyByKey("remoteendpoint").Split(':'); sb.Append("<html><body><h1>Client:</h1>"); sb.Append("Client IP Address : " + IpAddr[0] + "<br>"); sb.Append("Client Port : " + IpAddr[1] + "<br>"); sb.Append("Browser Information : " + request.getPropertyByKey("user-agent") + "<br>"); sb.Append("Accept Language : " + request.getPropertyByKey("accept-language") + "<br>"); sb.Append("Accept Encoding : " + request.getPropertyByKey("accept-encoding") + "<br>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; //600611024 and 600611030 give me an idea and teach me StringBuilder sb = new StringBuilder(); string[] getter = request.getPropertyByKey("RemoteEndPoint").Split(':'); sb.Append("<html><body>Client IP: " + getter[0] + "</br></br>"); sb.Append("Client Port: " + getter[1] + "</br></br>"); sb.Append("Browser Information: " + request.getPropertyByKey("User-Agent") + "</br></br>"); sb.Append("Accept-Language: " + request.getPropertyByKey("Accept-Language") + "</br></br>"); sb.Append("Accept-Encoding: " + request.getPropertyByKey("Accept-Encoding")); //600611039 help me for this sb.Append("</br>Threads-count: " + Process.GetCurrentProcess().Threads.Count); sb.Append("<br>Threads State : " + Thread.CurrentThread.ThreadState); sb.Append("<br>Threads ID : " + Thread.CurrentThread.ManagedThreadId); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { String[] ip = Regex.Split(request.getPropertyByKey("RemoteEndPoint"), ":"); HTTPResponse response = null; StringBuilder sb = new StringBuilder(); sb.Append("<html><body>"); sb.Append("Client IP: ").Append(ip[0]).Append("<br><br>"); sb.Append("Client Port: ").Append(ip[1]).Append("<br><br>"); sb.Append("Browser Information: ").Append(request.getPropertyByKey("User-Agent")).Append("<br><br>"); sb.Append("Accept Language: ").Append(request.getPropertyByKey("Accept-Language")).Append("<br><br>"); sb.Append("Accept-Encoding: " + request.getPropertyByKey("Accept-Encoding") + "</br></br>"); sb.Append("Thread ID: " + Thread.CurrentThread.ManagedThreadId + "</br></br>"); sb.Append("Thread status: " + Thread.CurrentThread.ThreadState); sb.Append("Amount of thread: " + Process.GetCurrentProcess().Threads.Count); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); sb.Append("<html><body>"); //Keep client IP[0] and port[1] p.s.RemoteEndPoint show IP:port String[] clientIP_Port = request.getPropertyByKey("RemoteEndPoint").Split(":"); //Show client's info sb.Append("<b>" + "Client IP: " + "</b>" + clientIP_Port[0] + "<br> <br>"); sb.Append("<b>" + "Client Port: " + "</b>" + clientIP_Port[1] + "<br> <br>"); sb.Append("<b>" + "Browser Information: " + "</b>" + request.getPropertyByKey("user-agent") + "<br> <br>"); sb.Append("<b>" + "Accept Language: " + "</b>" + request.getPropertyByKey("accept-language") + "<br> <br>"); sb.Append("<b>" + "Accept Encoding: " + "</b>" + request.getPropertyByKey("accept-encoding") + "<br> <br>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); sb.Append("<html><body><h1>CLIENT INFO</h1>"); String[] ip = request.getPropertyByKey("RemoteEndPoint").Split(":"); // split ip and port /// Show the results sb.Append("<h2>Sahatham Promthongpan 620615034</h2>"); sb.Append("<h3>" + "Client IP Address: " + "<span>" + ip[0] + "</span>" + "</h3>"); sb.Append("<h3>" + "Client Port: " + "<span>" + ip[1] + "</span>" + "</h3>"); sb.Append("<h3>" + "Browser Information: " + "<span>" + request.getPropertyByKey("user-agent") + "</span>" + "</h3>"); sb.Append("<h3>" + "Accept-Charset: " + "<span>" + request.getPropertyByKey("accept-language") + "</span>" + "</h3>"); sb.Append("<h3>" + "Accept-Encoding: " + "<span>" + request.getPropertyByKey("accept-encoding") + "</span>" + "</h3>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { //Name:Pongsakorn Thongaram ID:620615026 HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] showip = request.getPropertyByKey("RemoteEndPoint").Split(":"); String Browse = request.getPropertyByKey("user-agent"); String Language = request.getPropertyByKey("accept-language"); String encode = request.getPropertyByKey("accept-encoding"); sb.Append("<html><body style=font-family:Courier New>"); sb.Append("<p> Client ip: " + showip[0] + "</p>"); sb.Append("<p> Client port: " + showip[1] + "</p>"); sb.Append("<p> Browser Information: " + Browse + "</p>"); sb.Append("<p> Accept Language: " + Language + "</p>"); sb.Append("<p> Accept Encoding: " + encode + "</p>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String collect = request.getPropertyByKey("remoteendpoint"); String[] Ip = collect.Split(':'); String Browser = request.getPropertyByKey("user-agent"); String Language = request.getPropertyByKey("accept-language"); String Encode = request.getPropertyByKey("accept-encoding"); sb.Append("<html><body><h1>Client Information</h1>"); sb.Append("Client IP: " + Ip[0]); sb.Append("<br>Client Port: " + Ip[1]); sb.Append("<br>Browser Information: " + Browser); sb.Append("<br>Accept Language: " + Language); sb.Append("<br>Accept Encoding: " + Encode); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { request.getPropertyByKey("RemoteEndPoint"); string _req = request.req; HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] arr = _req.Split("User-Agent:"); string[] arr2 = arr[1].Split("Accept"); string[] arr3 = _req.Split("Accept-Encoding:"); string[] arr4 = arr3[1].Split("Accept"); string[] arr5 = _req.Split("Accept-Language:"); string[] port1 = request.getPropertyByKey("RemoteEndPoint").Split(":"); string[] port = request.getPropertyByKey("RemoteEndPoint").Split(":"); // string[] arr3 = _req. sb.Append("<html><body><h1>Client IP : " + port[0] + "</h1>"); sb.Append("<html><body><h1>Port : " + port[1] + "</h1>"); sb.Append("<html><body><h1>Browser information : " + arr2[0] + "</h1>"); foreach (KeyValuePair <String, int> entry in statDictionary) { sb.Append(entry.Key + ": " + entry.Value.ToString() + "<br />"); } sb.Append("<html><body><h1>Accept-Language : " + arr5[1] + "</h1> <br>"); sb.Append("<html><body><h1>Accept-Encoding : " + arr4[0] + "</h1> <br>"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); String[] client = Regex.Split(request.getPropertyByKey("RemoteEndPoint"), ":"); sb.Append("<html><body>"); sb.Append("Client IP: " + client[0].ToString() + "<br /><br />"); sb.Append("Client Port: " + client[1].ToString() + "<br /><br />"); sb.Append("Browser Information: " + request.getPropertyByKey("user-agent").ToString() + "<br /><br />"); sb.Append("Acept Language: " + request.getPropertyByKey("accept-language").ToString() + "<br /><br />"); sb.Append("Acept Encoding: " + request.getPropertyByKey("accept-encoding").ToString() + "<br /><br />"); // sb.Append("<html><body><h1>Stat:</h1>"); // foreach (KeyValuePair<String, int> entry in statDictionary) // { // sb.Append(entry.Key + ": " + entry.Value.ToString() + "<br />"); // } // response = new HTTPResponse(200); sb.Append("</body></html>"); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] ip = request.getPropertyByKey("RemoteEndPoint").Split(":"); //array ip type string collect the data in type string so it make ip=ip[0] port=ip[1] //split ip and port by using : to seperate them ---> ip : port sb.Append("<html><body><p>Client IP : " + ip[0] + "</p>"); //ip sb.Append("<p>Client Port : " + ip[1] + "</p>"); //port sb.Append("<p>Browser Information : " + request.getPropertyByKey("User-Agent") + "</p>"); sb.Append("<p>Accept Language : " + request.getPropertyByKey("Accept-Language") + "</p>"); sb.Append("<p>Accept Encoding : " + request.getPropertyByKey("Accept-Encoding") + "</p>"); sb.Append("<p>Thread ID : " + Thread.CurrentThread.ManagedThreadId + "</p>"); Process thispro = Process.GetCurrentProcess(); //collect process int threadnum = thispro.Threads.Count; //count thread number int thisproID = thispro.Id; //collect process ID sb.Append("<p>Process ID : " + thisproID + "</p>"); //display process ID sb.Append("<p>Number of Thread : " + threadnum + "</p>"); //display thread number //threadpool ThreadPool.GetAvailableThreads(out int thread_available, out int io); //get available number of worker and io ThreadPool.GetMaxThreads(out int max_thread, out int max_io); //get max number of worker and io sb.Append("<p>Available Thread : " + thread_available + "</p>"); //show available thread sb.Append("<p>Maximum Thread : " + max_thread + "</p>"); //show maximum thread sb.Append("<p>Active Thread : " + (max_thread - thread_available) + "</p>"); //display active thread sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] port = request.getPropertyByKey("RemoteEndPoint").Split(':'); sb.Append("<html><body>Client IP: " + port[0] + "</br></br>"); sb.Append("Client Port: " + port[1] + "</br></br>"); sb.Append("Browser Information: " + request.getPropertyByKey("UserAgent") + "</br></br>"); sb.Append("AcceptLanguage: " + request.getPropertyByKey("AcceptLanguage") + "</br></br>"); sb.Append("AcceptEncoding: " + request.getPropertyByKey("AcceptEncoding") + "</br></br>"); sb.Append("Number of Thread: " + Process.GetCurrentProcess().Threads.Count + "</br></br>"); //threadpool ThreadPool.GetAvailableThreads(out int workthreads, out int completionportthreads); ThreadPool.GetMaxThreads(out int maxworkthreads, out int maxcompletionportthreads); sb.Append("Maximum number of worker threads: " + maxworkthreads + "</br/></br>"); sb.Append("Available threads in thread pool: " + workthreads + "</br></br>"); sb.Append("Active threads in thread pool: " + (maxworkthreads - workthreads) + "</br></br>"); // sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { //teach by purit 600611039 and REF:https://en.wikipedia.org/wiki/List_of_HTTP_header_fields HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string port_ip = request.getPropertyByKey("RemoteEndPoint"); //GET ip and port of client. string [] ans = port_ip.Split(':'); //Split ip and port by :. sb.Append("<br>Clinet IP : " + ans[0]); //show ip sb.Append("<br>Client Port : " + ans[1]); //show port sb.Append("<br>Browser Information :" + request.getPropertyByKey("User-Agent")); //show Browser Information. sb.Append("<br>Accept-Charset : " + request.getPropertyByKey("Accept-Language")); //show support Language. sb.Append("<br>Accept-Encoding : " + request.getPropertyByKey("Accept-Encoding")); //show Encoding. //ref : https://stackoverflow.com/questions/15381174/how-to-count-the-amount-of-concurrent-threads-in-net-application. sb.Append("<br>Amount of concurrent threads : " + Process.GetCurrentProcess().Threads.Count); //show amount of concurrent threads. //ref : https://stackoverflow.com/questions/1679243/getting-the-thread-id-from-a-thread. sb.Append("<br>Threads name : " + Thread.CurrentThread.Name); //show Threads name. sb.Append("<br>Threads ID : " + Thread.CurrentThread.ManagedThreadId); //show Threads ID. sb.Append("<br>Threads State : " + Thread.CurrentThread.ThreadState); //show Threads State. response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] ipandport = request.getPropertyByKey("RemoteEndPoint").Split(':');//My friend 600611030 advise me to do this and told me to see in this web https://en.wikipedia.org/wiki/List_of_HTTP_header_fields sb.Append("<html><body>Client IP : " + ipandport[0]); sb.Append("<br>Port : " + ipandport[1]); sb.Append("<br>Browser : " + request.getPropertyByKey("User-Agent")); sb.Append("<br>Accept Language :" + request.getPropertyByKey("Accept-Language")); sb.Append("<br>Accept Encoding : " + request.getPropertyByKey("Accept-Encoding")); sb.Append("<br>" + "Thread ID: " + Thread.CurrentThread.ManagedThreadId); //I learn from answers in this web https://stackoverflow.com/questions/1679243/getting-the-thread-id-from-a-thread sb.Append("<br>" + "Thread count: " + Process.GetCurrentProcess().Threads.Count + "</br>"); //My friend 600611030 advise me ThreadPool.GetAvailableThreads(out int workers, out int completion); ThreadPool.GetMaxThreads(out int max_workers, out int max_completion); sb.Append("Size of thread pool: " + max_workers + "<br />"); sb.Append("Available threads in thread pool: " + workers + "<br />"); sb.Append("Active threads in thread pool: " + (max_workers - workers) + "<br />"); sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] ipport = request.getPropertyByKey("RemoteEndPoint").Split(':'); sb.Append("<html><body>Client IP: " + ipport[0] + "</br></br>"); sb.Append("Client Port: " + ipport[1] + "</br></br>"); sb.Append("Browser Information: " + request.getPropertyByKey("User-Agent") + "</br></br>"); sb.Append("Accept-Language: " + request.getPropertyByKey("Accept-Language") + "</br></br>"); sb.Append("Accept-Encoding: " + request.getPropertyByKey("Accept-Encoding") + "</br></br>"); sb.Append("</body></html>"); sb.Append("Number of Thread: " + Process.GetCurrentProcess().Threads.Count + "</br></br>"); //ref from https://stackoverflow.com/questions/15381174/how-to-count-the-amount-of-concurrent-threads-in-net-application //and 600611030 give me advices sb.Append("Amount of thread: " + Process.GetCurrentProcess().Threads.Count + "</br></br>"); ThreadPool.GetAvailableThreads(out int workerThreads, out int completionPortThreads); ThreadPool.GetMaxThreads(out int max_workerThreads, out int max_completionPortThreads); sb.Append("Maximum number of worker threads: " + max_workerThreads + "</br/></br>"); sb.Append("Available threads in thread pool: " + workerThreads + "</br></br>"); sb.Append("Active threads in thread pool: " + (max_workerThreads - workerThreads) + "</br></br>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { string box = request.info; //use .info to return the request's information HTTPResponse response = null; StringBuilder sb = new StringBuilder(); ///SPLITTING/// string[] cli_info = request.getPropertyByKey("RemoteEndpoint").Split(':'); //get the information from request which are stored in the RemoteEndpoint /// ///DISPLAY/// sb.Append("<html><body><p>Client IP: " + cli_info[0] + "</p>"); //Show the information before the colon sb.Append("</body><p>Client Port: " + cli_info[1] + "</p></html>"); ////Show the information after the colon ///////////// foreach (KeyValuePair <String, int> entry in statDictionary) { sb.Append(entry.Key + ": " + entry.Value.ToString() + "<br />"); } ///SPLITTING/// string[] split1 = box.Split("User-Agent:"); //split the string at "User-Agent" string[] split2 = box.Split("Accept-Encoding"); //split the string at "Accept-Encoding" string[] split3 = box.Split("Accept-Language"); //split the string at "Accept-Language" string[] ac_lang = split2[1].Split("Accept-Language"); //Resplit again to cut the ending part string[] browser = split1[1].Split("Accept"); //Resplit again to cut the ending part //////////////// ///DISPLAY/// sb.Append("</body><p>Browser Information: " + browser[0] + "</p></html>"); //Display the browser info -use the string that has already splited sb.Append("</body><p>Acept-Language " + split3[1] + "</p></html>"); //Display the Accept-Language info -use the string that has already splited sb.Append("</body><p>Acept-Encoding " + ac_lang[0] + "</p></html>"); //Display the Accept-Encoding info -use the string that has already splited ///////////// ///Tracking/// ADVICE FROM 600611001 //sb.Append("<div>CurrentThread ID : " + Thread.CurrentThread.ManagedThreadId + "</div><br>"); //check whether 1 thread is for 1 connection or not //sb.Append("<div>Thread Status : " + Thread.CurrentThread.ThreadState + "</div><br>"); //Display the thread's status //sb.Append("<div>Thread IsAlive : " + Thread.CurrentThread.IsAlive + "</div><br>"); //Display whether thread is alive or not sb.Append("<div>Number of threads : " + Process.GetCurrentProcess().Threads.Count + "</div><br>"); //Display the numbers of thread ThreadPool.GetAvailableThreads(out int available, out int io); ThreadPool.GetMaxThreads(out int maximum_thread, out int completionPortThreads); //sb.Append("<div>Number of threads : " + + "</div><br>"); ////////////// sb.Append("<div>Number of available threads: " + available + "</div><br>"); //Show available number of thread sb.Append("<div>Number of maximum usable threads: " + maximum_thread + "</div><br>"); //Show maximum usable thread sb.Append("<div>Number of active threads: " + (maximum_thread - available) + "</div><br>"); //Show active thread response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }
public HTTPResponse GetResponse(HTTPRequest request) { HTTPResponse response = null; StringBuilder sb = new StringBuilder(); string[] tmp = request.getPropertyByKey("RemoteEndpoint").Split(':'); //pon(1010) told me string IP = tmp[0]; // keep ip address string Port = tmp[1]; //keep port number string[] B = request.Get_B.Split("User-Agent: "); //keep Browser info string[] L = request.Get_L.Split("Accept-Language: "); //keep Language info string[] E = request.Get_E.Split("Accept-Encoding: "); //keep Encoding info sb.Append("<html><body> <b>Client IP</b>: " + IP); //return ip address sb.Append("<br /> <b>Client Port</b>: " + Port); //return port number sb.Append("<br /> <b>Browser Information</b>: " + B[1]); //return port number sb.Append("<br /> <b>Accept Language</b>: " + L[1]); //return port number sb.Append("<br /> <b>Accept Encoding</b>: " + E[1]); //return port number foreach (KeyValuePair <String, int> entry in statDictionary) { sb.Append(entry.Key + ": " + entry.Value.ToString() + "<br />"); } sb.Append("<br /><br /> <b>Thread ID</b>: " + Thread.CurrentThread.ManagedThreadId); //return Thread ID sb.Append("<br /><b>Process ID</b>: " + Process.GetCurrentProcess().Id); //return Process ID //600611010 tell me ThreadPool.GetAvailableThreads(out int available, out int io); ThreadPool.GetMaxThreads(out int max_T, out int completionPortThreads); sb.Append("<br /><br /> <b>Number of threads</b>: " + available); //return number of thread sb.Append("<br /> <b>Number of available threads</b>: " + max_T); //return number of available thread sb.Append("<br /> <b>Number of active threads</b>: " + (max_T - available)); //return thread which active sb.Append("</body></html>"); response = new HTTPResponse(200); response.body = Encoding.UTF8.GetBytes(sb.ToString()); return(response); }