本文整理汇总了C#中Bend.Util.HttpProcessor类的典型用法代码示例。如果您正苦于以下问题:C# HttpProcessor类的具体用法?C# HttpProcessor怎么用?C# HttpProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpProcessor类属于Bend.Util命名空间,在下文中一共展示了HttpProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: handleGETRequest
public override void handleGETRequest(HttpProcessor p)
{
Console.WriteLine("request: {0}", p.http_url);
p.writeSuccess();
//p.outputStream.WriteLine("<html><body><h1>test server</h1>");
//p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
//p.outputStream.WriteLine("url : {0}", p.http_url);
//p.outputStream.WriteLine("<form method=post action=/form>");
//p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
//p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
//p.outputStream.WriteLine("</form>");
if (p.http_url.Contains("www"))
{
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string fileName = appPath + "/" + p.http_url.Substring(p.http_url.IndexOf("www"));
FileInfo fi = new FileInfo(fileName);
using (StreamReader sr = new StreamReader(fi.OpenRead()))
{
p.outputStream.Write(sr.ReadToEnd());
}
}
else
{
System.Web.Script.Serialization.JavaScriptSerializer j = new System.Web.Script.Serialization.JavaScriptSerializer();
p.outputStream.WriteLine(j.Serialize(Temps));
}
}
开发者ID:skthumperd,项目名称:SharpTemp,代码行数:31,代码来源:MyHttpServer.cs
示例2: handleGETRequest
public override void handleGETRequest(HttpProcessor processor)
{
Console.WriteLine("--GET REQUEST BEGIN--");
Console.WriteLine("Request:\n\t" + processor.http_url);
Console.WriteLine("Parameter:");
Console.WriteLine("\nSearching Handler..");
foreach (ITaskReciverPlugin cmd in pluginLoader.LoadedPlugins)
{
if (processor.http_url.StartsWith(cmd.CommandTrigger))
{
Console.Write(" Found!");
List<Tuple<string, string>> param = new List<Tuple<string,string>>();
param = GetParams(processor.http_url, cmd.CommandTrigger);
param.ForEach(x => Console.WriteLine("\t" + x.Item1 + " = " + ((x.Item2 == "") ? "no value" : x.Item2)));
Console.WriteLine("Executing!");
Console.WriteLine("--GET REQUEST END--\n");
cmd.Execute(param);
processor.writeSuccess();
return;
}
}
processor.writeFailure();
Console.Write(" Non Found :(");
Console.WriteLine("--GET REQUEST END--\n");
}
开发者ID:Kimmax,项目名称:TaskReceiver,代码行数:32,代码来源:Server.cs
示例3: CopyHeaders
private void CopyHeaders(HttpProcessor p, Recipe engine)
{
foreach (string key in p.HttpHeaders.Keys)
{
engine.SetMacro("q_" + key, p.HttpHeaders[key]);
}
int i = p.HttpUrl.IndexOf('?');
string path;
if (i == -1)
{
path = Unescape(p.HttpUrl);
}
else
{
path = Unescape(p.HttpUrl.Substring(0, i));
var query = p.HttpUrl.Substring(i + 1); // skip '?'
string[] pairs = query.Split('&');
foreach (string s in pairs)
{
string u = Unescape(s);
string[] t = u.Split('=');
string key = t[0];
string value = t.Length == 1 ? "" : t[1];
engine.SetMacro("q_" + key, value); // try to avoid clashing with existing macros by prefixing with q_
}
}
engine.SetMacro("query", path);
}
开发者ID:ashish-antil,项目名称:Products,代码行数:29,代码来源:RecipeServer.cs
示例4: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
Console.WriteLine("--POST REQUEST BEGIN--");
Console.WriteLine("Request:\n\t" + p.http_url);
Console.WriteLine("Answer:\n\tPost request not supported.");
Console.WriteLine("--POST REQUEST END--\n");
}
开发者ID:Kimmax,项目名称:TaskReceiver,代码行数:7,代码来源:Server.cs
示例5: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
Console.WriteLine("POST request: {0}", p.http_url);
string data = inputData.ReadToEnd();
Console.WriteLine(data);
try
{
var log = ToLog(data);
var ok_msg = "{\"code\":\"0\",\"msg\":\"ok\"}";
var msg_len = Encoding.UTF8.GetByteCount(ok_msg);
ProcessLog(log);
p.outputStream.Write("HTTP/1.0 200 OK\r\n");
p.outputStream.Write("Cache-Control: private, max-age=0\r\n");
p.outputStream.Write("Content-Type: text/html\r\n");
p.outputStream.Write(string.Format("Content-Length:{0}\r\n", msg_len));
p.outputStream.Write("Vary: Accept-Encoding\r\n");
p.outputStream.Write("Server: Microsoft-IIS/8.5\r\n\r\n");
p.outputStream.Write(ok_msg);
}
catch
{
p.outputStream.Write("HTTP/1.0 404 NOT FOUND\r\n");
p.outputStream.Write("Content-Length:0\r\n");
p.outputStream.Write("Content-Type: text/html\r\n");
p.outputStream.Write("Server: Microsoft-IIS/8.5\r\n\r\n");
}
}
开发者ID:xdusongwei,项目名称:RpcTracker,代码行数:27,代码来源:RpcHttpServer.cs
示例6: WriteForm
private void WriteForm(HttpProcessor p)
{
string source = "PROGRAM test.";
try {
StreamReader stream = new StreamReader ("Test.abap");
source = stream.ReadToEnd ();
stream.Close ();
} catch (Exception e) {
}
p.writeSuccess ();
p.outputStream.WriteLine ("<html>");
p.outputStream.WriteLine ("<head>");
p.outputStream.WriteLine ("<script src=\"client.js\" type=\"text/javascript\"></script>");
p.outputStream.WriteLine ("</head>");
p.outputStream.WriteLine ("<body>");
p.outputStream.WriteLine ("<h1>openABAP</h1>");
p.outputStream.WriteLine ("<form name=screen method=get action=\"\">");
p.outputStream.WriteLine ("<textarea name=source cols=120 rows=30>");
p.outputStream.WriteLine (source);
p.outputStream.WriteLine ("</textarea>");
p.outputStream.WriteLine ("<input type=submit name=sy-ucomm value=OK onclick=\"return send();\">");
p.outputStream.WriteLine ("<br/><textarea name=result cols=120 rows=10 readonly></textarea>");
p.outputStream.WriteLine ("</form></body></html>");
}
开发者ID:bi-tm,项目名称:openABAP,代码行数:25,代码来源:Server.cs
示例7: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
if (p.http_url.ToLower().Contains("setalarm"))
{
string args = inputData.ReadToEnd();
System.Web.Script.Serialization.JavaScriptSerializer j = new System.Web.Script.Serialization.JavaScriptSerializer();
SetAlarmArgs saa = j.Deserialize<SetAlarmArgs>(args);
if (NewAlarm != null)
{
if(saa.temp.Length == 0){
NewAlarm(saa.index, null);
}else{
double dbl = 0;
if(double.TryParse(saa.temp, out dbl)){
NewAlarm(saa.index, dbl);
}else{
NewAlarm(saa.index, null);
}
}
}
//NewAlarm(p.httpHeaders["temp"]);
p.outputStream.WriteLine( "ok");
}
else
{
Console.WriteLine("POST request: {0}", p.http_url);
string data = inputData.ReadToEnd();
p.outputStream.WriteLine("<html><body><h1>test server</h1>");
p.outputStream.WriteLine("<a href=/test>return</a><p>");
p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
}
}
开发者ID:duwke,项目名称:SharpTemp,代码行数:34,代码来源:MyHttpServer.cs
示例8: Deal
private void Deal(HttpProcessor p,string url, string data,bool isGet){
if(url==null){
return;
}
if(url=="/"||url.StartsWith("/room.php")||url.StartsWith("/room.json")){
//房间列表
p.writeSuccess();
p.outputStream.Write(GetContent(url, data));
}else if(url.StartsWith("/deck.php")){
//卡片列表
if(data.IndexOf("pwd=caicai")<0){
p.writeFailure();
return;
}
p.writeSuccess();
string[] args = data.Split('&');
foreach(string a in args){
if(a != null && a.StartsWith("name=")){
int i = a.IndexOf("=");
if(i>=0 && i< a.Length-1){
string name = a.Substring(i+1);
List<int> cards = GameManager.GameCards(name);
foreach(int id in cards){
p.outputStream.WriteLine(""+id);
}
}
}
}
}
else{
p.writeFailure();
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:33,代码来源:MyHttpServer.cs
示例9: HandlePOSTRequest
public override void HandlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
//Console.WriteLine("POST request: {0}", p.HttpUrl);
var engine = (Recipe)_Engine.Clone();
CopyHeaders(p, engine);
engine.SetMacro(Response, inputData.ReadToEnd());
engine.Run(new LineReader(_Script, "POST"));
WriteResponse(p, engine);
}
开发者ID:ashish-antil,项目名称:Products,代码行数:9,代码来源:RecipeServer.cs
示例10: HandleGETRequest
public override void HandleGETRequest(HttpProcessor p)
{
//Console.WriteLine("request: {0}", p.HttpUrl);
var engine = (Recipe)_Engine.Clone();
CopyHeaders(p, engine);
engine.SetMacro(Response, "");
engine.Run(new LineReader(_Script, "GET"));
WriteResponse(p, engine);
}
开发者ID:ashish-antil,项目名称:Products,代码行数:9,代码来源:RecipeServer.cs
示例11: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
Console.WriteLine("POST request: {0}", p.http_url);
string data = inputData.ReadToEnd();
p.outputStream.WriteLine("<html><body><h1>test server</h1>");
p.outputStream.WriteLine("<a href=/test>return</a><p>");
p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
}
开发者ID:skthumperd,项目名称:SharpTemp,代码行数:9,代码来源:MyHttpServer.cs
示例12: handleGETRequest
public override void handleGETRequest(HttpProcessor p)
{
string urlText = p.http_url;
int pos = urlText.IndexOf("&");
if (pos != -1)
{
urlText = urlText.Substring(0, pos);
}
if (urlText.EndsWith("/getSnapshot") == true)
{
p.writeSuccess("application/json");
p.outputStream.Write(_document.SnapshotText);
}
else if (urlText.Contains("/setSlide/") == true)
{
string txt = urlText.Substring(urlText.LastIndexOf('/') + 1);
int slide;
if (Int32.TryParse(txt, out slide) == true)
{
_document.SetCurrentSlide(slide);
}
p.writeSuccess("text/html");
p.outputStream.Write("OK");
}
else if (urlText.Contains("/startShow/") == true)
{
string txt = urlText.Substring(urlText.LastIndexOf('/') + 1);
int slide;
if (Int32.TryParse(txt, out slide) == true)
{
_document.StartShow(slide);
}
p.writeSuccess("text/html");
p.outputStream.Write("OK");
}
else if (urlText.Contains("/startShow") == true)
{
_document.StartShow(1);
p.writeSuccess("text/html");
p.outputStream.Write("OK");
}
else if (urlText.Contains("/nextAnimation") == true)
{
_document.NextAnimation();
p.writeSuccess("text/html");
p.outputStream.Write("OK");
}
}
开发者ID:stjeong,项目名称:OfficePresenter,代码行数:54,代码来源:MyHttpServer.cs
示例13: listen
public void listen()
{
listener = new TcpListener(server, port);
listener.Start();
while (is_active)
{
TcpClient s = listener.AcceptTcpClient();
HttpProcessor processor = new HttpProcessor(s, this);
Thread thread = new Thread(new ThreadStart(processor.process));
thread.Start();
Thread.Sleep(1);
}
}
开发者ID:honomoa,项目名称:SimpleHttpServer,代码行数:13,代码来源:HttpServer.cs
示例14: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
Console.WriteLine("POST request: {0}", p.http_url);
var stopWatch = new Stopwatch();
stopWatch.Start();
string data = inputData.ReadToEnd();
var board = JsonConvert.DeserializeObject<DynaShipBoard>(data);
var response = new DynaShipAI(board).Process();
p.writeSuccess("application/json");
p.outputStream.Write(String.Format("{{\"x\": {0}, \"y\": {1}}}", response.X, response.Y));
stopWatch.Stop();
Console.WriteLine("Time taken: " + stopWatch.Elapsed);
}
开发者ID:nilsgudmundsson,项目名称:DynaShipClientCSharp,代码行数:15,代码来源:DynaShipServer.cs
示例15: handleGETRequest
public override void handleGETRequest(HttpProcessor p)
{
Console.WriteLine("request: {0}", p.http_url);
p.writeSuccess();
string callback = String.Empty;
this.setData(ParseParameters(p.http_url, out callback));
try
{
p.outputStream.WriteLine(callback + "(\"OK\")");
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
}
开发者ID:n0nick,项目名称:pewpew,代码行数:17,代码来源:KinectHttpServer.cs
示例16: handleGETRequest
public override void handleGETRequest(HttpProcessor p) {
//Console.WriteLine("request: {0}", p.http_url);
if(p.http_url==null){
p.writeFailure();
return;
}
int index=p.http_url.IndexOf("?");
string url=p.http_url;
string arg="";
if(index>0){
url=p.http_url.Substring(0, index);
if(index+1<p.http_url.Length){
arg=p.http_url.Substring(index+1);
}
}
Deal(p, url, arg, true);
}
开发者ID:247321453,项目名称:YgoServer,代码行数:17,代码来源:MyHttpServer.cs
示例17: listen
public override void listen()
{
base.listener = new TcpListener(IPAddress.Any, port); // moualem changed
listener.Start();
while (is_active)
{
TcpClient s = null;
try
{
s = listener.AcceptTcpClient();
}
catch
{
return;
}
HttpProcessor processor = new HttpProcessor(s, this);
Thread thread = new Thread(new ThreadStart(processor.process));
thread.Start();
Thread.Sleep(1);
}
}
开发者ID:n0nick,项目名称:pewpew,代码行数:21,代码来源:KinectHttpServer.cs
示例18: handlePOSTRequest
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
Console.WriteLine("POST request: {0}", p.http_url);
// write source in post body to server file
StreamWriter file = new StreamWriter("temp.abap");
inputData.BaseStream.CopyTo(file.BaseStream);
file.Close();
// compile
openABAP.Compiler.Compiler compiler = new openABAP.Compiler.Compiler("temp.abap");
try {
compiler.Compile();
compiler.Run ();
p.outputStream.WriteLine(openABAP.Runtime.Runtime.Output);
} catch (openABAP.Compiler.CompilerError ex) {
p.outputStream.WriteLine(ex.Message);
p.outputStream.WriteLine(compiler.GetErrors());
}
// ready
//p.writeSuccess();
}
开发者ID:bi-tm,项目名称:openABAP,代码行数:21,代码来源:Server.cs
示例19: handleGETRequest
public override void handleGETRequest(HttpProcessor p)
{
var reader = new StreamReader("index.html");
var content = reader.ReadToEnd();
var length = Encoding.UTF8.GetByteCount(content);
p.outputStream.Write("HTTP/1.0 200 OK\r\n");
p.outputStream.Write("Cache-Control: private, max-age=0\r\n");
p.outputStream.Write("Content-Type: text/html\r\n");
p.outputStream.Write(string.Format("Content-Length:{0}\r\n", length));
p.outputStream.Write("Vary: Accept-Encoding\r\n");
p.outputStream.Write("Server: Microsoft-IIS/8.5\r\n\r\n");
p.outputStream.Write(content);
reader.Close();
if (p.http_url.Equals("/Test.png"))
{
}
Console.WriteLine("request: {0}", p.http_url);
}
开发者ID:xdusongwei,项目名称:RpcTracker,代码行数:22,代码来源:RpcHttpServer.cs
示例20: handleGETRequest
public override void handleGETRequest(HttpProcessor p)
{
Console.WriteLine ("request: {0}", p.http_url);
if (p.http_url.Equals ("/")) {
// return form
WriteForm (p);
} else {
//return static file
try {
FileInfo f = new FileInfo(p.http_url.TrimStart('/'));
if (f.Exists) {
StreamReader s = new StreamReader(f.FullName);
p.writeSuccess();
p.outputStream.Write(s.ReadToEnd());
} else {
p.writeFailure();
}
} catch(Exception e) {
p.writeFailure();
}
}
}
开发者ID:bi-tm,项目名称:openABAP,代码行数:22,代码来源:Server.cs
注:本文中的Bend.Util.HttpProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论