当前位置: 首页>>代码示例>>C#>>正文


C# MiniHttpd.HttpRequest类代码示例

本文整理汇总了C#中MiniHttpd.HttpRequest的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest类的具体用法?C# HttpRequest怎么用?C# HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequest类属于MiniHttpd命名空间,在下文中一共展示了HttpRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的MiniHttpd.HttpRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。