本文整理汇总了C#中MiniHttpd.HttpRequest类的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest类的具体用法?C# HttpRequest怎么用?C# HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequest类属于MiniHttpd命名空间,在下文中一共展示了HttpRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetPageData
public override Dictionary<string, object> GetPageData(HttpRequest request, IDirectory directory)
{
Dictionary<string,object> d = new Dictionary<string,object>();
d.Add("MarqueeText", MainClass.Sanitise(MainClass.settings.GetMarqueeText()));
d.Add("NotepadText", MainClass.Sanitise(MainClass.settings.GetNotepadText()));
d.Add("Timeout", 10);
d.Add("Fonts", new string[] {"placeholder"});
d.Add("Font", "placeholder");
d.Add("EventNameFull", MainClass.Sanitise(MainClass.settings.GetEventNameFull()));
/*
* d.Add("MarqueeText", Main.Sanitise(mw.MarqueeText));
d.Add("NotepadText", Main.Sanitise(mw.LanSettings.Notepad));
d.Add("Timeout", mw.LanSettings.NotepadTimeout);
d.Add("Fonts", Main.Sanitise(mw.LanSettings.Fonts.ToArray()));
*/
//Pango.FontDescription fd = Pango.FontDescription.FromString(mw.LanSettings.NotepadFont);
//d.Add("Font", Main.Sanitise(fd.Family));
// UGLY HACK ALERT
// this really should be done properly, however the font size reported in the fontdescription is the wrong
// unit and no suitable conversion function to points is quickly available.
//try {
// d.Add("FontSize", int.Parse(mw.LanSettings.NotepadFont.Remove(0,fd.Family.Length+1)));
//} catch (FormatException) { // some fonts have incorrect family names for some reason, another thing to fix.
d.Add("FontSize", 30);
//}
return d;
}
开发者ID:micolous,项目名称:SAGAPresenter2,代码行数:30,代码来源:Index.cs
示例2: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
Console.WriteLine("[EXIT] Disconnecting users..");
System.Threading.Thread.Sleep(1000);
foreach (KeyValuePair<Guid, User> entry in users)
{
try {
User user = entry.Value;
//Guid session = (Guid)entry.Key;
if (user.Events != null)
{
user.Events.Network_Disconnected(this, new DisconnectedEventArgs(NetworkManager.DisconnectType.ServerInitiated, "Your deviMobile session has timed out."));
Console.WriteLine("[EXIT] Transmitted logout alert to " + user.Client.Self.FirstName + " " + user.Client.Self.LastName + ". Waiting...");
System.Threading.Thread.Sleep(1000);
user.Events.deactivate();
}
Console.WriteLine("[EXIT] Disconnecting " + user.Client.Self.FirstName + " " + user.Client.Self.LastName + "...");
user.Client.Network.Logout();
} catch(Exception e) {
Console.WriteLine("[ERROR] " + e.Message);
}
}
System.Threading.Thread.Sleep(1000);
Console.WriteLine("[EXIT] Done.");
Environment.Exit(0);
}
开发者ID:deviSAS,项目名称:j2me-client,代码行数:32,代码来源:Exit.cs
示例3: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
try
{
Guid key = Guid.NewGuid();
StreamReader reader = new StreamReader(request.PostData);
string qstring = reader.ReadToEnd();
reader.Dispose();
Dictionary<string, string> POST = deviMobile.PostDecode(qstring);
User user = User.CreateUser(); //(int)POST["screenWidth"], (int)POST["screenHeight"]);
lock (users) users.Add(key, user);
Hashtable ret = new Hashtable();
ret.Add("id", key.ToString("D"));
ret.Add("ch", user.Challenge);
writer.Write(MakeJson.FromHashtable(ret));
writer.Flush();
}
catch (IOException e)
{
writer.Write(e.Message);
writer.Flush();
}
}
开发者ID:deviSAS,项目名称:j2me-client,代码行数:29,代码来源:CreateSession.cs
示例4: OnFileRequested
/// <summary>
/// Called when the file is requested by a client.
/// </summary>
/// <param name="request">The <see cref="HttpRequest"/> requesting the file.</param>
/// <param name="directory">The <see cref="IDirectory"/> of the parent directory.</param>
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
ICollection dirs;
ICollection files;
try
{
dirs = directory.GetDirectories();
files = directory.GetFiles();
}
catch(UnauthorizedAccessException)
{
throw new HttpRequestException("403");
}
request.Response.BeginChunkedOutput();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
writer.WriteLine("<html>");
writer.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
writer.WriteLine("<head><title>Index of " + HttpWebServer.GetDirectoryPath(directory) + "</title></head>");
writer.WriteLine("<body>");
PrintBody(writer, request, directory, dirs, files);
writer.WriteLine("<hr>" + request.Server.ServerName);
writer.WriteLine("</body></html>");
writer.WriteLine("</body>");
writer.WriteLine("</html>");
writer.Flush();
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:36,代码来源:IndexPage.cs
示例5: PrintBody
internal virtual void PrintBody(StreamWriter writer,
HttpRequest request,
IDirectory directory,
ICollection dirs,
ICollection files
)
{
writer.WriteLine("<h2>Index of " + HttpWebServer.GetDirectoryPath(directory) + "</h2>");
if(directory.Parent != null)
writer.WriteLine("<a href=\"..\">[..]</a><br>");
foreach(IDirectory dir in dirs)
{
//if(dir is IPhysicalResource)
// if((File.GetAttributes((dir as IPhysicalResource).Path) & FileAttributes.Hidden) != 0)
// continue;
writer.WriteLine("<a href=\"" + UrlEncoding.Encode(dir.Name) + "/\">[" + dir.Name + "]</a><br>");
}
foreach(IFile file in files)
{
//if(file is IPhysicalResource)
// if((File.GetAttributes((file as IPhysicalResource).Path) & FileAttributes.Hidden) != 0)
// continue;
writer.WriteLine("<a href=\"" + UrlEncoding.Encode(file.Name) + "\">" + file.Name + "</a><br>");
}
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:30,代码来源:IndexPage.cs
示例6: OnFileRequested
/// <summary>
/// Called when the file is requested by a client.
/// </summary>
/// <param name="request">The <see cref="HttpRequest"/> requesting the file.</param>
/// <param name="directory">The <see cref="IDirectory"/> of the parent directory.</param>
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
if(request.IfModifiedSince != DateTime.MinValue)
{
if(File.GetLastWriteTimeUtc(path) < request.IfModifiedSince)
request.Response.ResponseCode = "304";
return;
}
if(request.IfUnmodifiedSince != DateTime.MinValue)
{
if(File.GetLastWriteTimeUtc(path) > request.IfUnmodifiedSince)
request.Response.ResponseCode = "304";
return;
}
if(System.IO.Path.GetFileName(path).StartsWith("."))
{
request.Response.ResponseCode = "403";
return;
}
try
{
request.Response.ResponseContent = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
}
catch(FileNotFoundException)
{
request.Response.ResponseCode = "404";
}
catch(IOException e)
{
request.Response.ResponseCode = "500";
request.Server.Log.WriteLine(e);
}
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:40,代码来源:DriveFile.cs
示例7: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ContentType = request.Query["type"];
this.contenttype = request.Query["type"];
request.Response.ResponseContent = new MemoryStream();
StreamWriter textWriter = new StreamWriter(request.Response.ResponseContent);
textWriter.Write(request.Query["content"]);
textWriter.Flush();
}
开发者ID:cfire24,项目名称:ajaxlife,代码行数:9,代码来源:MakeFile.cs
示例8: blink1Id
// /blink1/id -- Display blink1_id and blink1 serial numbers (if any)
static string blink1Id(HttpRequest request, blinkServer bs)//example
{
string serial = bs.getId();
return @"{
""blink1_id"": ""44288083" + serial + @""",
""blink1_serialnums"": [
""" + serial + @"""
],
""status"": ""blink1 id""
}";
}
开发者ID:Toshi,项目名称:blink1,代码行数:13,代码来源:blinkServer.cs
示例9: GetPageData
public override Dictionary<string, object> GetPageData(HttpRequest request, IDirectory directory)
{
Dictionary<string,object> d = new Dictionary<string,object>();
// save the data back
Console.WriteLine("Setting to {0}.", request.Query.Get("marqueeText"));
MainClass.settings.SetMarqueeText(request.Query.Get("marqueeText"));
MainClass.settings.FireSettingsChanged();
d.Add("Redirect", "index.html");
return d;
}
开发者ID:micolous,项目名称:SAGAPresenter2,代码行数:11,代码来源:MarqueeCommit.cs
示例10: PrintBody
internal override void PrintBody(StreamWriter writer,
HttpRequest request,
IDirectory directory,
ICollection dirs,
ICollection files
)
{
bool reverse = request.Query["desc"] != null;
ResourceColumn sort = ResourceColumn.None;
try
{
string sortString = request.Query["sort"];
if(sortString != null && sortString != string.Empty)
sort = (ResourceColumn)Enum.Parse(typeof(ResourceColumn), sortString);
}
catch(ArgumentException)
{
}
writer.WriteLine("<h2>Index of " + MakeLinkPath(directory, request) + "</h2>");
writer.WriteLine("<table cellspacing=\"0\">");
writer.WriteLine("<tr>");
foreach(ResourceColumn column in columns)
{
writer.Write(GetColumnTd(column) + "<b><a href=\"" + "." + "?sort=" + column.ToString());
if(sort == column && !reverse)
writer.Write("&desc");
writer.Write("\"/>");
writer.WriteLine(column.ToString() + "</a></b></td>");
}
writer.WriteLine("</tr>");
ArrayList entries = new ArrayList(dirs.Count + files.Count);
foreach(IDirectory dir in dirs)
entries.Add(new ResourceEntry(dir));
foreach(IFile file in files)
entries.Add(new ResourceEntry(file));
if(sort != ResourceColumn.None)
entries.Sort(new ResourceComparer(reverse, sort));
foreach(ResourceEntry entry in entries)
entry.WriteHtml(writer, columns);
writer.WriteLine("</table>");
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:52,代码来源:IndexPageEx.cs
示例11: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
Guid key = Guid.NewGuid();
User user = User.CreateUser();
lock(users) users.Add(key, user);
Hashtable ret = new Hashtable();
ret.Add("SessionID", key.ToString("D"));
ret.Add("Challenge", user.Challenge);
ret.Add("Exponent", StringHelper.BytesToHexString(AjaxLife.RSAp.Exponent));
ret.Add("Modulus", StringHelper.BytesToHexString(AjaxLife.RSAp.Modulus));
ret.Add("Grids", AjaxLife.LOGIN_SERVERS.Keys);
ret.Add("DefaultGrid", AjaxLife.DEFAULT_LOGIN_SERVER);
writer.Write(MakeJson.FromHashtable(ret));
writer.Flush();
}
开发者ID:cfire24,项目名称:ajaxlife,代码行数:17,代码来源:CreateSession.cs
示例12: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
try {
Dictionary<string, object> d = GetPageData(request, directory);
d.Add("Version", MainClass.Version);
d.Add("GenerationTime", DateTime.Now.ToString("F"));
writer.Write(template.Generate(d));
} catch (HTTPDErrorException ex) {
writer.Write(ex.GenerateErrorPage());
} catch (Exception ex) {
HTTPDErrorException hex = new HTTPDErrorException(String.Format("Unhandled Exception: {0}", ex.GetType().FullName), String.Format("An exception ({0}) was thrown that was not handled and turned into a HTTPDErrorException properly. It's message was: {1}", ex.GetType().FullName, ex.Message), ex);
writer.Write(hex.GenerateErrorPage());
}
writer.Flush();
}
开发者ID:micolous,项目名称:SAGAPresenter2,代码行数:17,代码来源:SimplePageWrapper.cs
示例13: MakeLinkPath
string MakeLinkPath(IDirectory directory, HttpRequest request)
{
StringBuilder sb = new StringBuilder();
ArrayList pathList = new ArrayList();
for(IDirectory dir = directory; dir != null; dir = dir.Parent)
pathList.Add(dir.Name);
pathList.RemoveAt(pathList.Count-1);
pathList.Reverse();
sb.Append("<a href=\"" + request.Uri.Scheme + "://" + request.Uri.Host);
if(request.Uri.Port != 80)
sb.Append(":" + request.Uri.Port);
sb.Append("/\">");
sb.Append(request.Uri.Host + "</a>");
if(pathList.Count > 0)
sb.Append(" - ");
StringBuilder reassembledPath = new StringBuilder();
for(int i = 0; i < pathList.Count; i++)
{
string path = pathList[i] as string;
sb.Append("<a href=\"/");
reassembledPath.Append(UrlEncoding.Encode(path));
reassembledPath.Append("/");
sb.Append(reassembledPath.ToString());
sb.Append("\">");
sb.Append(path);
if(i < pathList.Count-1)
sb.Append("</a>/");
else
sb.Append("</a>");
}
return sb.ToString();
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:46,代码来源:IndexPageEx.cs
示例14: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
StreamReader reader = new StreamReader(request.PostData);
string post = reader.ReadToEnd();
reader.Dispose();
Dictionary<string, string> POST = AjaxLife.PostDecode(post);
Hashtable hash = new Hashtable();
hash.Add("SESSION_ID", POST["sid"]);
hash.Add("STATIC_ROOT", AjaxLife.STATIC_ROOT);
Html.Template.Parser parser = new Html.Template.Parser(hash);
writer.Write(parser.Parse(File.ReadAllText("Html/Templates/iPhone.html")));;
writer.Flush();
}
开发者ID:cfire24,项目名称:ajaxlife,代码行数:18,代码来源:iPhone.cs
示例15: RequestEventArgs
internal RequestEventArgs(HttpClient client, HttpRequest request) : base(client)
{
this.request = request;
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:4,代码来源:ClientEventArgs.cs
示例16: Ublink1Pattern
// -----------------------------------------------------------------------------------------------
// color patterns url handling
//
// /blink1/pattern/ -- List saved color patterns
static string Ublink1Pattern(HttpRequest request, Blink1Server blink1Server)
{
Dictionary<string, object> result = new Dictionary<string, object>();
result.Add("status", "pattern results");
result.Add("patterns", blink1Server.patterns.Values);
return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings);
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:12,代码来源:Blink1Server.cs
示例17: OnFileRequested
public void OnFileRequested(HttpRequest request,
IDirectory directory)
{
// Assign a MemoryStream to hold the response content.
request.Response.ResponseContent = new MemoryStream();
// Create a StreamWriter to which we
// can write some text, and write to it.
StreamWriter writer =
new StreamWriter(request.Response.ResponseContent);
writer.WriteLine(GetStringResponse(request, bs));
// Don't forget to flush!
writer.Flush();
}
开发者ID:Toshi,项目名称:blink1,代码行数:16,代码来源:blinkServer.cs
示例18: GetPageData
public virtual Dictionary<string, object> GetPageData(HttpRequest request, IDirectory directory)
{
return null;
}
开发者ID:micolous,项目名称:SAGAPresenter2,代码行数:4,代码来源:SimplePageWrapper.cs
示例19: OnFileRequested
public void OnFileRequested(HttpRequest request, IDirectory directory)
{
request.Response.ResponseContent = new MemoryStream();
StreamWriter writer = new StreamWriter(request.Response.ResponseContent);
try
{
// Generate a new session ID.
Guid key = Guid.NewGuid();
// Create a new User.
User user = new User();
// Set the user session properties.
user.LastRequest = DateTime.Now;
user.Rotation = -Math.PI;
// Generate a single-use challenge key.
user.Challenge = "123";
// Add the session to the users.
lock (users) users.Add(key, user);
Hashtable hash = new Hashtable();
// Set up the template with useful details and the challenge and public key.
hash.Add("STATIC_ROOT", deviMobile.STATIC_ROOT);
hash.Add("SESSION_ID", key.ToString("D"));
hash.Add("CHALLENGE", user.Challenge);
// Make the grid list, ensuring the default one is selected.
string grids = "";
foreach (string server in deviMobile.LOGIN_SERVERS.Keys)
{
grids += "<option value=\"" + System.Web.HttpUtility.HtmlAttributeEncode(server) +
"\"" + (server == deviMobile.DEFAULT_LOGIN_SERVER ? " selected=\"selected\"" : "") + ">" +
System.Web.HttpUtility.HtmlEncode(server) + "</option>\n";
}
hash.Add("GRID_OPTIONS", grids);
if (deviMobile.HANDLE_CONTENT_ENCODING)
{
hash.Add("ENCODING", "identity");
// S3 doesn't support Accept-Encoding, so we do it ourselves.
if (request.Headers["Accept-Encoding"] != null)
{
string[] accept = request.Headers["Accept-Encoding"].Split(',');
foreach (string encoding in accept)
{
string parsedencoding = encoding.Split(';')[0].Trim();
if (parsedencoding == "gzip" || parsedencoding == "*") // Should we really honour "*"? Specs aside, it's never going to be true.
{
hash["ENCODING"] = "gzip";
break;
}
}
}
}
// Parse the template.
Html.Template.Parser parser = new Html.Template.Parser(hash);
writer.Write(parser.Parse(File.ReadAllText("Html/Templates/index.html")));
}
catch (Exception exception)
{
this.contenttype = "text/plain";
writer.WriteLine("Error: " + exception.Message);
}
writer.Flush();
}
开发者ID:deviSAS,项目名称:j2me-client,代码行数:60,代码来源:MainPage.cs
示例20: Ublink1PatternStopAll
// /blink1/pattern/stopall -- Stop all pattern playback
static string Ublink1PatternStopAll(HttpRequest request, Blink1Server blink1Server)
{
blink1Server.stopAllPatterns();
Dictionary<string, object> result = new Dictionary<string, object>();
result.Add("status", "all patterns stopped");
return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings);
}
开发者ID:GotenXiao,项目名称:blink1,代码行数:8,代码来源:Blink1Server.cs
注:本文中的MiniHttpd.HttpRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论