本文整理汇总了C#中HttpServer.HttpServer类的典型用法代码示例。如果您正苦于以下问题:C# HttpServer类的具体用法?C# HttpServer怎么用?C# HttpServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpServer类属于HttpServer命名空间,在下文中一共展示了HttpServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
var path = this.GetPath(request.Uri);
var html = System.IO.Path.Combine(path, "index.html");
var htm = System.IO.Path.Combine(path, "index.htm");
if (System.IO.Directory.Exists(path) && (System.IO.File.Exists(html) || System.IO.File.Exists(htm)))
{
if (!request.Uri.AbsolutePath.EndsWith("/"))
{
response.Redirect(request.Uri.AbsolutePath + "/");
return true;
}
response.Status = System.Net.HttpStatusCode.OK;
response.Reason = "OK";
response.ContentType = "text/html; charset=utf-8";
using (var fs = System.IO.File.OpenRead(System.IO.File.Exists(html) ? html : htm))
{
response.ContentLength = fs.Length;
response.Body = fs;
response.Send();
}
return true;
}
return false;
}
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:30,代码来源:IndexHtmlHandler.cs
示例2: OnRequest
private void OnRequest(object sender, HttpServer.RequestEventArgs e)
{
string[] paramss = e.Request.UriParts;
HttpServer.IHttpResponse resp = e.Request.CreateResponse((IHttpClientContext)sender);
if (paramss[0] == "favicon.ico")
{
reactFavIco(resp);
}
if (paramss[0] == "fire")
{
reactFire(resp);
}
if (paramss[0] == "move")
{
reactMove(resp,paramss[1]);
}
if (paramss[0] == "laser")
{
reactLaser(resp);
}
if (paramss[0] == "reset")
{
reactReset(resp);
}
}
开发者ID:drewbuschhorn,项目名称:STRIKER-II---C--Webserver,代码行数:30,代码来源:Program.cs
示例3: HandleCreateAccount
private static string HandleCreateAccount(HttpServer server, HttpListenerRequest request, Dictionary<string, string> parameters)
{
if (!parameters.ContainsKey("username")) throw new Exception("Missing username.");
if (!parameters.ContainsKey("password")) throw new Exception("Missing password.");
string username = parameters["username"];
string password = parameters["password"];
if (Databases.AccountTable.Count(a => a.Username.ToLower() == username.ToLower()) > 0) return JsonEncode("Username already in use!");
System.Text.RegularExpressions.Regex invalidCharacterRegex = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]");
if (invalidCharacterRegex.IsMatch(username)) return JsonEncode("Invalid characters detected in username!");
Random getrandom = new Random();
String token = getrandom.Next(10000000, 99999999).ToString();
AccountEntry entry = new AccountEntry();
entry.Index = Databases.AccountTable.GenerateIndex();
entry.Username = username;
entry.Password = password;
entry.Verifier = "";
entry.Salt = "";
entry.RTW_Points = 0;
entry.IsAdmin = 0;
entry.IsBanned = 0;
entry.InUse = 0;
entry.extrn_login = 0;
entry.CanHostDistrict = 1;
entry.Token = token;
Databases.AccountTable.Add(entry);
Log.Succes("HTTP", "Successfully created account '" + username + "'");
return JsonEncode("Account created!\n\nYour token is: " + token + ".\nCopy and paste given token in \"_rtoken.id\" file and put it in the same folder where your \"APB.exe\" is located.");
}
开发者ID:fiki574,项目名称:rAPB,代码行数:33,代码来源:HttpServer.Handlers.cs
示例4: DefaultRackServer
public DefaultRackServer(int port,IPAddress ipAddress,ILogWriter logWriter)
{
_server = new HttpServer.HttpServer(logWriter);
_ipAddress = ipAddress;
_port = port;
_logWriter = logWriter;
}
开发者ID:PlasticLizard,项目名称:Bracket,代码行数:7,代码来源:DefaultRackServer.cs
示例5: ResourceServer
public ResourceServer()
{
_httpServerV4 = new HttpServer.HttpServer(new HttpLogWriter());
_httpServerV6 = new HttpServer.HttpServer(new HttpLogWriter());
ResourceAccessModule module = new ResourceAccessModule();
AddHttpModule(module);
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:7,代码来源:ResourceServer.cs
示例6: HttpRequest
bool _streamingrequestbody; // indicates that request body can be streamed by user
#endregion Fields
#region Constructors
internal HttpRequest(HttpServer._Connection connection, HttpMethod method, string rawpath)
{
_connection = connection;
_method = method;
_rawpath = rawpath;
int iof = rawpath.IndexOf('?');
_path = iof >= 0 ? rawpath.Substring(0, iof) : rawpath;
}
开发者ID:blucz,项目名称:wikipad,代码行数:14,代码来源:http_server.cs
示例7: Run
public void Run(IBackgroundTaskInstance taskInstance)
{
// Get the deferral object from the task instance
serviceDeferral = taskInstance.GetDeferral();
httpServer = new HttpServer(8000);
httpServer.StartServer();
}
开发者ID:DrexelECE,项目名称:SrDes2016-41,代码行数:8,代码来源:StartupTask.cs
示例8: ObjectForScripting
public ObjectForScripting()
{
httpServer = new HttpServer.HttpServer();
ajaxObjectForScripting = new AjaxObjectForScripting(this);
httpServer.Add(ajaxObjectForScripting);
httpServer.Start(IPAddress.Any, 50505);
httpServer.BackLog = 5;
}
开发者ID:cpbuck12,项目名称:Db,代码行数:8,代码来源:ObjectForScripting.cs
示例9: WebService
private WebService()
{
this._server = new H.HttpServer();
var res = new ResourceFileModule();
res.AddResources("/", typeof(WebService).Assembly, "XSpect.Contributions.Solar.Resources.Documents");
this._server.Add(res);
this._server.Add(new RequestHandler());
this.Configuration = new ExpandoObject();
}
开发者ID:takeshik,项目名称:solar-contribs,代码行数:9,代码来源:WebService.cs
示例10: PollServiceHttpRequest
public PollServiceHttpRequest(
PollServiceEventArgs pPollServiceArgs, HttpServerLib.HttpClientContext pHttpContext, HttpServerLib.HttpRequest pRequest)
{
PollServiceArgs = pPollServiceArgs;
HttpContext = pHttpContext;
Request = pRequest;
RequestTime = System.Environment.TickCount;
RequestID = UUID.Random();
}
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:9,代码来源:PollServiceHttpRequest.cs
示例11: Main
private static void Main(string[] args)
{
var config = new DefaultHttpServerConfiguration() { Port = 8080, Handler = new DefaultHtmlRequestHandler("U:/CustomServer", new[] { "index.html", "default.html" }) };
var server = new HttpServer(config);
server.ConnectionEstablished += Server_ConnectionEstablished;
server.ConnectionLost += Server_ConnectionLost;
server.MessageSent += server_MessageSent;
server.MessageReceived += server_MessageReceived;
server.Start();
Thread.Sleep(new TimeSpan(0,5,0));
server.Stop();
}
开发者ID:xsteviex,项目名称:HttpServer,代码行数:12,代码来源:Program.cs
示例12: Main
static void Main(string[] args)
{
if (!EasyServer.InitConfig("Configs/Database.xml", "Database")) return;
Databases.InitDB();
Databases.Load();
HttpServer.MapHandlers();
HttpServer server = new HttpServer();
server.Start();
Timer aTimer = new Timer(10000);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
Console.ReadLine();
}
开发者ID:fiki574,项目名称:rAPB,代码行数:14,代码来源:Program.cs
示例13: AddXSRFTokenToRespone
private bool AddXSRFTokenToRespone(HttpServer.IHttpResponse response)
{
if (m_activexsrf.Count > 500)
return false;
var buf = new byte[32];
var expires = DateTime.UtcNow.AddMinutes(XSRF_TIMEOUT_MINUTES);
m_prng.GetBytes(buf);
var token = Convert.ToBase64String(buf);
m_activexsrf.Add(token, expires);
response.Cookies.Add(new HttpServer.ResponseCookie(XSRF_COOKIE_NAME, token, expires));
return true;
}
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:14,代码来源:AuthenticationHandler.cs
示例14: FindAuthCookie
private string FindAuthCookie(HttpServer.IHttpRequest request)
{
var authcookie = request.Cookies[AUTH_COOKIE_NAME] ?? request.Cookies[Library.Utility.Uri.UrlEncode(AUTH_COOKIE_NAME)];
var authform = request.Form["auth-token"] ?? request.Form[Library.Utility.Uri.UrlEncode("auth-token")];
var authquery = request.QueryString["auth-token"] ?? request.QueryString[Library.Utility.Uri.UrlEncode("auth-token")];
var auth_token = authcookie == null || string.IsNullOrWhiteSpace(authcookie.Value) ? null : authcookie.Value;
if (authquery != null && !string.IsNullOrWhiteSpace(authquery.Value))
auth_token = authquery["auth-token"].Value;
if (authform != null && !string.IsNullOrWhiteSpace(authform.Value))
auth_token = authform["auth-token"].Value;
return auth_token;
}
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:14,代码来源:AuthenticationHandler.cs
示例15: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
client = new WebClient();
client.Encoding = Encoding.UTF8;
var info = new OBBInfo();
info.ip = IPAddress.Loopback.ToString();
info.notifyPort = Settings.Default.notifyPort;
info.servicePort = Settings.Default.servicePort;
info.serviceRoot = Settings.Default.serviceRoot;
if (String.IsNullOrWhiteSpace(info.serviceRoot))
info.serviceRoot = Environment.CurrentDirectory;
OBBContext.Current.Info = info;
OBBContext.Current.Mode = Settings.Default.mode;
server = new HttpServer.HttpServer();
var fileModule = new FileModule("/", OBBContext.Current.Info.serviceRoot);
var myModule = new MyModule();
fileModule.AddDefaultMimeTypes();
server.Add(myModule);
server.Add(fileModule);
server.Start(IPAddress.Any, OBBContext.Current.Info.servicePort);
if (OBBContext.Current.IsMaster)
{
OBBContext.Current.MasterInfo = OBBContext.Current.Info;
notifyIcon1.Icon = Resources.master;
var port = IPAddress.HostToNetworkOrder(OBBContext.Current.Info.servicePort);
byte[] portData = BitConverter.GetBytes(port);
notify = new UdpNotify(OBBContext.Current.Info.notifyPort, portData);
}
else
{
OBBContext.Current.LoadGameConfig();
notifyIcon1.Icon = Resources.slave;
notify = new UdpNotify(OBBContext.Current.Info.notifyPort);
notify.OnData += Notify_OnData;
}
this.Text = OBBContext.Current.Mode.ToString();
notifyIcon1.Text = OBBContext.Current.Mode.ToString();
refreshTimer.Start();
button1.Enabled = OBBContext.Current.IsMaster;
}
开发者ID:john-guo,项目名称:hodgepodge,代码行数:48,代码来源:Form1.cs
示例16: GetCore
internal HttpServer.HttpServer GetCore()
{
if(core == null)
{
// create my dispatcher module
var testModule = new DispatcherModule(GetClassList());
// create session handling
var customComponents = new ComponentProvider();
var sessionStore = new MemorySessionStore();
sessionStore.ExpireTime = 5;
customComponents.AddInstance<IHttpSessionStore>(sessionStore);
core = new HttpServer.HttpServer(customComponents);
core.Add(new HttpModuleWrapper(testModule));
}
return core;
}
开发者ID:Lyror,项目名称:EmployeeManagement,代码行数:19,代码来源:WebServer.cs
示例17: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
if ((request.Uri.AbsolutePath == "/" || request.Uri.AbsolutePath == "/index.html" || request.Uri.AbsolutePath == "/index.htm") && System.IO.File.Exists(m_defaultdoc))
{
response.Status = System.Net.HttpStatusCode.OK;
response.Reason = "OK";
response.ContentType = "text/html";
using (var fs = System.IO.File.OpenRead(m_defaultdoc))
{
response.ContentLength = fs.Length;
response.Body = fs;
response.Send();
}
return true;
}
return false;
}
开发者ID:Berimor66,项目名称:duplicati,代码行数:20,代码来源:IndexHtmlHandler.cs
示例18: AddXSRFTokenToRespone
private bool AddXSRFTokenToRespone(HttpServer.IHttpResponse response)
{
if (m_activexsrf.Count > 500)
return false;
var buf = new byte[32];
var expires = DateTime.UtcNow.AddMinutes(XSRF_TIMEOUT_MINUTES);
m_prng.GetBytes(buf);
var token = Convert.ToBase64String(buf);
m_activexsrf.AddOrUpdate(token, key => expires, (key, existingExpires) =>
{
// Simulate the original behavior => if the random token, against all odds, is already used
// we throw an ArgumentException
throw new ArgumentException("An element with the same key already exists in the dictionary.");
});
response.Cookies.Add(new HttpServer.ResponseCookie(XSRF_COOKIE_NAME, token, expires));
return true;
}
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:20,代码来源:AuthenticationHandler.cs
示例19: StartTutorial
public void StartTutorial()
{
_server = new HttpServer.HttpServer();
// Let's use Digest authentication which is superior to basic auth since it
// never sends password in clear text.
DigestAuthentication auth = new DigestAuthentication(OnAuthenticate, OnAuthenticationRequired);
_server.AuthenticationModules.Add(auth);
// simple example of an regexp redirect rule. Go to http://localhost:8081/profile/arne to get redirected.
_server.Add(new RegexRedirectRule("/profile/(?<first>[a-zA-Z0-9]+)", "/user/view/${first}"));
// Let's reuse our module from previous tutorial to handle pages.
_server.Add(new Tutorial3.MyModule());
// and start the server.
_server.Start(IPAddress.Any, 8081);
Console.WriteLine("Goto http://localhost:8081/membersonly to get authenticated.");
Console.WriteLine("Password is 'morsOlle', and userName is 'arne'");
}
开发者ID:oblivious,项目名称:Oblivious,代码行数:21,代码来源:Tutorial4.cs
示例20: FindXSRFToken
private string FindXSRFToken(HttpServer.IHttpRequest request)
{
string xsrftoken = request.Headers[XSRF_HEADER_NAME] ?? "";
if (string.IsNullOrWhiteSpace(xsrftoken))
xsrftoken = Duplicati.Library.Utility.Uri.UrlDecode(xsrftoken);
if (string.IsNullOrWhiteSpace(xsrftoken))
{
var xsrfq = request.Form[XSRF_HEADER_NAME] ?? request.Form[Duplicati.Library.Utility.Uri.UrlEncode(XSRF_HEADER_NAME)];
xsrftoken = (xsrfq == null || string.IsNullOrWhiteSpace(xsrfq.Value)) ? "" : xsrfq.Value;
}
if (string.IsNullOrWhiteSpace(xsrftoken))
{
var xsrfq = request.QueryString[XSRF_HEADER_NAME] ?? request.QueryString[Duplicati.Library.Utility.Uri.UrlEncode(XSRF_HEADER_NAME)];
xsrftoken = (xsrfq == null || string.IsNullOrWhiteSpace(xsrfq.Value)) ? "" : xsrfq.Value;
}
return xsrftoken;
}
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:21,代码来源:AuthenticationHandler.cs
注:本文中的HttpServer.HttpServer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论