本文整理汇总了C#中HttpServer.RequestEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# RequestEventArgs类的具体用法?C# RequestEventArgs怎么用?C# RequestEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestEventArgs类属于HttpServer命名空间,在下文中一共展示了RequestEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnRequestDesbloqueio
public void OnRequestDesbloqueio(object sender, RequestEventArgs e)
{
e.Response.Connection.Type = ConnectionType.Close;
e.Response.ContentType.Value = "text/xml";
if (unlockSent == 0)
{
unlockSent++;
string opcionais = "";
int numparams = 1;
if (checkBox1.Checked)
{
opcionais += "<ParameterValueStruct><Name>InternetGatewayDevice.Services.X_Pace_Com.Services.SSH.Enable</Name><Value xsi:type=\"xsd:unsignedInt\">1</Value></ParameterValueStruct>";
numparams++;
}
timer1.Stop();
AppendTextBox("\r\nModem conectado, enviando configuração.\r\n");
byte[] buffer = Encoding.Default.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap-env:Envelope xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\"><soap-env:Header><cwmp:ID soap-env:mustUnderstand=\"1\">55882f2177ab936c3f062f8f</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:SetParameterValues><ParameterList soap-enc:arrayType=\"cwmp:ParameterValueStruct["+numparams+"]\"><ParameterValueStruct><Name>InternetGatewayDevice.Services.X_Pace_Com.Services.GvtConfig.AccessClass</Name><Value xsi:type=\"xsd:unsignedInt\">4</Value></ParameterValueStruct>"+opcionais+"</ParameterList><ParameterKey/></cwmp:SetParameterValues></soap-env:Body></soap-env:Envelope>");
e.Response.Body.Write(buffer, 0, buffer.Length);
AppendTextBox("Finalizado.\r\n");
}
else if (unlockSent < 2)
{
unlockSent++;
byte[] buffer = Encoding.Default.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap-env:Envelope xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\"><soap-env:Header><cwmp:ID soap-env:mustUnderstand=\"1\">null</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:InformResponse><MaxEnvelopes>1</MaxEnvelopes></cwmp:InformResponse></soap-env:Body></soap-env:Envelope>");
e.Response.Body.Write(buffer, 0, buffer.Length);
}
else
{
unlockSent = 1;
e.Response.Status = HttpStatusCode.NoContent;
}
}
开发者ID:juliocaduraes,项目名称:GVT-Unlock,代码行数:34,代码来源:Form1.cs
示例2: OnRequest
private static void OnRequest(object sender, RequestEventArgs e)
{
if (e.Request.Method == Method.Post)
{
}
}
开发者ID:oblivious,项目名称:Oblivious,代码行数:7,代码来源:Program.cs
示例3: listener_RequestReceived
static void listener_RequestReceived(object sender, RequestEventArgs e)
{
var virtualPath = e.Request.Uri.AbsolutePath.TrimStart('/').Replace("/","\\");
var stream = ProcessPath(virtualPath, "index.html");
if (stream != null)
CopyStream(stream, e.Response.Body);
}
开发者ID:tocsoft,项目名称:WebsiteGenerator,代码行数:7,代码来源:Program.cs
示例4: Handle
public bool Handle(RequestEventArgs e)
{
NetworkRequest req = Multiplexor.Decode(e.Request);
logger.Trace("Client rx: {0} p: {1} source: {2} overlord: {3}", req.Verb, req.Param, req.SourceID,
req.OverlordID);
switch (req.Verb)
{
case "BROWSE":
return HandleBrowse(e, req);
case "UPDATE":
return HandleUpdate(e, req);
case "INFO":
return HandleInfo(e);
case "NOOP":
return HandleNOOP(e, req);
case "GET":
return HandleGet(e, req);
case "DISCONNECT":
return HandleDisconnect(e);
case "CHAT":
return HandleChat(e, req);
case "COMPARE":
return HandleCompare(e, req);
case "SEARCH":
return HandleSearch(e, req);
case "CONVERSTATION":
return HandleConversation(e, req);
case "ADDDOWNLOAD":
return HandleAddDownload(e, req);
}
return false;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:32,代码来源:FAPClientHandler.cs
示例5: OnSecureRequest
private void OnSecureRequest(object source, RequestEventArgs args)
{
IHttpClientContext context = (IHttpClientContext)source;
IHttpRequest request = args.Request;
// Here we create a response object, instead of using the client directly.
// we can use methods like Redirect etc with it,
// and we dont need to keep track of any headers etc.
IHttpResponse response = request.CreateResponse(context);
byte[] body = Encoding.UTF8.GetBytes("Hello secure you!");
response.Body.Write(body, 0, body.Length);
response.Send();
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:14,代码来源:Tutorial2.cs
示例6: OnRequest
private void OnRequest(object source, RequestEventArgs args)
{
IHttpClientContext context = (IHttpClientContext)source;
IHttpRequest request = args.Request;
// Respond is a small convenience function that let's you send one string to the browser.
// you can also use the Send, SendHeader and SendBody methods to have total control.
if (request.Uri.AbsolutePath == "/hello")
context.Respond("Hello to you too!");
else if (request.UriParts.Length == 1 && request.UriParts[0] == "goodbye")
{
IHttpResponse response = request.CreateResponse(context);
StreamWriter writer = new StreamWriter(response.Body);
writer.WriteLine("Goodbye to you too!");
writer.Flush();
response.Send();
}
}
开发者ID:kow,项目名称:Aurora-Sim,代码行数:19,代码来源:Tutorial1.cs
示例7: OnRequest
private static void OnRequest(object sender, RequestEventArgs e)
{
#if DEBUG
lock (_lockObj)
{
Console.WriteLine(("Begin Request").Wrap("-", Console.WindowWidth));
Console.WriteLine(string.Format("Request from {0}", e.Context.RemoteEndPoint.Address.ToString()));
if (e.Response.Status == HttpStatusCode.OK)
{
Console.WriteLine(string.Format("The request for {0} was successful", e.Request.Uri.ToString()));
}
else
{
Console.WriteLine(string.Format("The request for {0} failed", e.Request.Uri.ToString()));
}
Console.WriteLine(("End Request").Wrap("-", Console.WindowWidth));
}
#endif
}
开发者ID:seaboy1234,项目名称:MCAdmin,代码行数:19,代码来源:Webserver.cs
示例8: OnRequest
private void OnRequest(object sender, RequestEventArgs e)
{
String url = "https://v.whatsapp.net" + e.Request.Uri.PathAndQuery;
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
e.Response.ContentType.Value = response.ContentType;
e.Response.ContentLength.Value = response.ContentLength;
Stream responseStream = response.GetResponseStream();
StreamReader responseReader = new StreamReader(responseStream);
String data = responseReader.ReadToEnd();
byte[] data2 = Encoding.Default.GetBytes(data);
e.Response.Body.Write(data2, 0, data2.Length);
this.AddListItem("REQUEST: " + e.Request.Uri.AbsoluteUri);
this.AddListItem("RESPONSE: " + data);
this.AddListItem(" ");
}
开发者ID:rafavg77,项目名称:MissVenom,代码行数:20,代码来源:Form1.cs
示例9: ExecuteCommand
protected override object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms, RequestEventArgs e)
{
if (cmd.RequiresToken)
{
var strtoken = parms["token"];
if (strtoken == null)
return new Dictionary<string, string>
{{"status", "401"}, {"error", "Not authorized. The specified API endpoint requires a token."}};
object token;
if (!Tokens.TryGetValue(strtoken, out token))
return new Dictionary<string, string>
{
{"status", "403"},
{
"error",
"Not authorized. The specified API endpoint requires a token, but the provided token was not valid."
}
};
}
return base.ExecuteCommand(cmd, verbs, parms, e);
}
开发者ID:RogerPaladin,项目名称:TShock,代码行数:22,代码来源:SecureRest.cs
示例10: listener_RequestReceived
private void listener_RequestReceived(object sender, RequestEventArgs e)
{
e.IsHandled = true;
e.Response.Reason = string.Empty;
string userAgent = string.Empty;
IHeader uahead =
e.Request.Headers.Where(h => string.Equals("User-Agent", h.Name, StringComparison.OrdinalIgnoreCase)).
FirstOrDefault();
if (null != uahead)
userAgent = uahead.HeaderValue;
//Send to the correct handler
if (userAgent.StartsWith("FAP"))
{
if (OnRequest(RequestType.FAP, e))
return;
}
if (OnRequest(RequestType.HTTP, e))
return;
e.Response.Reason = "Handler error";
e.Response.Status = HttpStatusCode.InternalServerError;
var generator = new ResponseWriter();
generator.SendHeaders(e.Context, e.Response);
}
开发者ID:Kayomani,项目名称:FAP,代码行数:24,代码来源:NodeServer.cs
示例11: OnRequestReceived
private void OnRequestReceived(object sender, RequestEventArgs e)
{
RequestReceived(sender, e);
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:4,代码来源:HttpListenerBase.cs
示例12: HandleSearch
private bool HandleSearch(RequestEventArgs e, NetworkRequest req)
{
//We dont do this on a server..
var verb = new SearchVerb(shareInfoService);
NetworkRequest result = verb.ProcessRequest(req);
byte[] data = Encoding.UTF8.GetBytes(result.Data);
var generator = new ResponseWriter();
e.Response.ContentLength.Value = data.Length;
generator.SendHeaders(e.Context, e.Response);
e.Context.Stream.Write(data, 0, data.Length);
e.Context.Stream.Flush();
data = null;
return true;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:14,代码来源:FAPClientHandler.cs
示例13: OnHttpListenerRequestReceived
private void OnHttpListenerRequestReceived(object sender, RequestEventArgs e)
{
IHttpClientContext context = (IHttpClientContext)sender;
lock (_serverData.SyncObj)
if (!_serverData.IsActive)
return;
HandleHTTPRequest_NoLock(context, e.Request);
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:8,代码来源:UPnPServer.cs
示例14: OnRequest
protected virtual void OnRequest(object sender, RequestEventArgs e)
{
var obj = ProcessRequest(sender, e);
if (obj == null)
throw new NullReferenceException("obj");
var str = JsonConvert.SerializeObject(obj, Formatting.Indented);
e.Response.Connection.Type = ConnectionType.Close;
e.Response.Body.Write(Encoding.ASCII.GetBytes(str), 0, str.Length);
e.Response.Status = HttpStatusCode.OK;
return;
}
开发者ID:vharonftw,项目名称:TShock,代码行数:12,代码来源:Rest.cs
示例15: ProcessRequest
protected virtual object ProcessRequest(object sender, RequestEventArgs e)
{
var uri = e.Request.Uri.AbsolutePath;
uri = uri.TrimEnd('/');
foreach (var com in commands)
{
var verbs = new RestVerbs();
if (com.HasVerbs)
{
var match = Regex.Match(uri, com.UriVerbMatch);
if (!match.Success)
continue;
if ((match.Groups.Count - 1) != com.UriVerbs.Length)
continue;
for (int i = 0; i < com.UriVerbs.Length; i++)
verbs.Add(com.UriVerbs[i], match.Groups[i + 1].Value);
}
else if (com.UriTemplate.ToLower() != uri.ToLower())
{
continue;
}
var obj = ExecuteCommand(com, verbs, e.Request.Parameters);
if (obj != null)
return obj;
}
return new Dictionary<string, string> { { "status", "404" }, { "error", "Specified API endpoint doesn't exist. Refer to the documentation for a list of valid endpoints." } };
}
开发者ID:vharonftw,项目名称:TShock,代码行数:31,代码来源:Rest.cs
示例16: HandleInfo
private bool HandleInfo(RequestEventArgs e)
{
e.Response.Status = HttpStatusCode.OK;
var verb = new InfoVerb();
verb.Node = model.LocalNode;
NetworkRequest result = verb.CreateRequest();
byte[] data = Encoding.UTF8.GetBytes(result.Data);
var generator = new ResponseWriter();
e.Response.ContentLength.Value = data.Length;
generator.SendHeaders(e.Context, e.Response);
e.Context.Stream.Write(data, 0, data.Length);
e.Context.Stream.Flush();
return true;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:14,代码来源:FAPClientHandler.cs
示例17: HandleCompare
private bool HandleCompare(RequestEventArgs e, NetworkRequest req)
{
var verb = new CompareVerb(model);
NetworkRequest result = verb.ProcessRequest(req);
byte[] data = Encoding.UTF8.GetBytes(result.Data);
var generator = new ResponseWriter();
e.Response.ContentLength.Value = data.Length;
generator.SendHeaders(e.Context, e.Response);
e.Context.Stream.Write(data, 0, data.Length);
e.Context.Stream.Flush();
data = null;
return true;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:15,代码来源:FAPClientHandler.cs
示例18: OnRequest
protected virtual void OnRequest(object sender, RequestEventArgs e)
{
var obj = ProcessRequest(sender, e);
if (obj == null)
throw new NullReferenceException("obj");
if (OnRestRequestCall(e))
return;
var str = JsonConvert.SerializeObject(obj, Formatting.Indented);
var jsonp = e.Request.Parameters["jsonp"];
if (!string.IsNullOrWhiteSpace(jsonp))
{
str = string.Format("{0}({1});", jsonp, str);
}
e.Response.Connection.Type = ConnectionType.Close;
e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8");
e.Response.Add(serverHeader);
var bytes = Encoding.UTF8.GetBytes(str);
e.Response.Body.Write(bytes, 0, bytes.Length);
e.Response.Status = HttpStatusCode.OK;
}
开发者ID:Ijwu,项目名称:TShock,代码行数:22,代码来源:Rest.cs
示例19: HandleChat
private bool HandleChat(RequestEventArgs e, NetworkRequest req)
{
var verb = new ChatVerb();
verb.ReceiveResponse(req);
model.Messages.AddRotate(verb.Nickname + ":" + verb.Message, 50);
SendOk(e);
SafeObservingCollectionManager.UpdateNowAsync();
return true;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:9,代码来源:FAPClientHandler.cs
示例20: HandleGet
private bool HandleGet(RequestEventArgs e, NetworkRequest req)
{
//No url?
if (string.IsNullOrEmpty(req.Param))
return false;
string[] possiblePaths;
if (shareInfoService.ToLocalPath(req.Param, out possiblePaths))
{
foreach (string possiblePath in possiblePaths)
{
if (File.Exists(possiblePath))
{
var ffu = new FAPFileUploader(bufferService, serverUploadLimiterService);
var session = new TransferSession(ffu);
model.TransferSessions.Add(session);
try
{
//Try to find the username of the request
string userName = e.Context.RemoteEndPoint.Address.ToString();
Node search = model.Network.Nodes.ToList().Where(n => n.ID == req.SourceID).FirstOrDefault();
if (null != search && !string.IsNullOrEmpty(search.Nickname))
userName = search.Nickname;
using (
FileStream fs = File.Open(possiblePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
ffu.DoUpload(e.Context, fs, userName, possiblePath);
}
//Add log of upload
double seconds = (DateTime.Now - ffu.TransferStart).TotalSeconds;
var txlog = new TransferLog();
txlog.Nickname = userName;
txlog.Completed = DateTime.Now;
txlog.Filename = Path.GetFileName(possiblePath);
txlog.Path = Path.GetDirectoryName(req.Param);
if (!string.IsNullOrEmpty(txlog.Path))
{
txlog.Path = txlog.Path.Replace('\\', '/');
if (txlog.Path.StartsWith("/"))
txlog.Path = txlog.Path.Substring(1);
}
txlog.Size = ffu.Length - ffu.ResumePoint;
if (txlog.Size < 0)
txlog.Size = 0;
if (0 != seconds)
txlog.Speed = (int) (txlog.Size/seconds);
model.CompletedUploads.Add(txlog);
}
finally
{
model.TransferSessions.Remove(session);
}
return true;
}
}
}
e.Response.Status = HttpStatusCode.NotFound;
var generator = new ResponseWriter();
generator.SendHeaders(e.Context, e.Response);
return true;
}
开发者ID:Kayomani,项目名称:FAP,代码行数:67,代码来源:FAPClientHandler.cs
注:本文中的HttpServer.RequestEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论