internal override void WriteResponse(HttpRequest req) { this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Log", true); this.output.WriteLine("<h2>Log (mostly errors)</h2>"); // the following nasty bit of code is a temporary measure. // The Program.errors structure obviously needs to die, but at the moment it is simple and effective. this.output.WriteLine("<p>The following most recent errors have been caught (" + Program.errors.Count + " out of a maximum of 5): <br /></p>"); if (Program.errors.Count == 0) { output.WriteLine("There have been 0 errors (wow)!"); } else { this.output.WriteLine("<textarea readonly='true'>"); for (int i = 0; i < Math.Min(Program.errors.Count, 5); i++) { output.WriteLine(Program.errors[i] + "<br />"); } this.output.WriteLine("</textarea>"); } this.WriteTemplateFooter(); }
private static void ReadHttpHeader(HttpRequest req, string line) { string[] parts = line.Split(new char[] { ':' }, 2); if (parts.Length == 2) { req.headers[parts[0]] = parts[1]; } }
internal override void WriteResponse(HttpRequest req) { if (!req.urlArguments.ContainsKey("filename")) { throw new HttpException(404); } string filename = req.urlArguments["filename"]; string resourceContent = Resources.ResourceManager.GetString(filename); this.output.Write(resourceContent); }
internal override void WriteResponse(HttpRequest req) { this.contentType = "text/html"; try { this.WriteResponseHeader(); this.WriteTemplate(new TplContent(Resources.TplYouTube)); this.output.Flush(); } catch(Exception e ) { Program.errors.Add(e.ToString()); } }
internal override void WriteResponse(HttpRequest req) { this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Startup"); TplContent tpl = new TplContent(Resources.TplStartup); tpl.Assign("DATADIR", Application.CommonAppDataPath.Replace("\\", "/")); tpl.Assign("PORT", HttpServer.port); this.WriteTemplate(tpl); this.WriteTemplateFooter(); }
internal override void WriteResponse(HttpRequest req) { this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Library", true); TplContent tpl = new TplContent(Resources.TplLibrary); tpl.Assign("LIBSIZE", this.connectionHandler.server.library.Size()); this.WriteTemplate(tpl); // template doesnt support loops, yet. output.WriteLine("<ul>"); foreach (FileInfo fi in connectionHandler.server.library.All()) { output.WriteLine("<li>" + fi.FullName + "</li>"); } output.WriteLine("<ul>"); this.WriteTemplateFooter(); }
internal override void WriteResponse(HttpRequest req) { this.contentType = "text/html"; try { if (e is HttpException) { this.WriteResponseExceptionBasic(); } else { this.WriteResponseExceptionTemplated(); } } catch (Exception e) { Program.errors.Add(e.ToString()); } }
internal override void WriteResponse(HttpRequest req) { req.GetCookies(); this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Index", true); this.output.WriteLine("<p>Welcome to the Flexible Message Board (fmb!)</p>"); this.output.WriteLine("<h2>Queue</h2>"); if (Program.scheduler.GetQueue().Count == 0) { this.output.WriteLine("The queue is empty."); } else { foreach (DisplayableMessageArguments r in Program.scheduler.GetQueue()) { this.output.WriteLine(r.getControl().ToString()); } } this.WriteTemplateFooter(); }
internal override void WriteResponse(HttpRequest req) { if (!req.urlArguments.ContainsKey("form")) { throw new HttpException(HttpException.OBJECT_NOT_FOUND, "Form not specified"); } HtmlForm f = forms.Find(req.urlArguments["form"]); this.CheckFormAccess(f); f.Inject(this); f.action = string.Empty; f.AddElement(new ElementHidden("servlet", "Servlet", this.GetType().Name)); f.AddElement(new ElementHidden("form", "Form", f.GetType().Name)); if (f.Validate(req.urlArguments)) { f.Process(); if (f.postProcessContent != null) { this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Login successful"); this.output.Write(f.postProcessContent); this.WriteTemplateFooter(); return; } } this.contentType = "text/html"; this.WriteResponseHeader(); this.WriteTemplateHeader("Form: " + f.Title, true); f.Render(this.output); this.WriteTemplateFooter(); }
internal override void WriteResponse(HttpRequest req) { this.WriteResponseHeader(); this.WriteTemplateHeader("Sessions"); this.WriteTemplateFooter(); }
private static HttpRequest ReadRequestHttpMethod(string line) { string[] components = line.Split(' '); HttpRequest req = new HttpRequest(); if (components.Length != 3) { throw new HttpException(400); // FIXME bad request. } if (!components[0].Equals("GET")) { throw new HttpException(401, "Unsupported HTTP method: " + line); } req.url = Uri.UnescapeDataString(components[1]); req.url = req.url.Replace("&", "&"); if (req.url.Contains("?")) { string query = req.url.Split(new char[] { '?' }, 2)[1]; foreach (string s in query.Split('&')) { string[] s2 = s.Split(new char[] { '=' }, 2); if (s2.Length == 2) { req.urlArguments[s2[0]] = s2[1]; } else { req.urlArguments[s2[0]] = string.Empty; } } } return req; }
internal override void WriteResponse(HttpRequest req) { Program.scheduler.Clear(); this.output.WriteLine("<p>The queue has been flushed.</p>"); }
internal override void WriteResponse(HttpRequest req) { this.output.WriteLine("Next..."); }
internal override void WriteResponse(HttpRequest req) { Program.canNextShoutout = Program.canNextShoutout.AddMinutes(10); this.output.WriteLine("Can next shoutout at: " + Program.canNextShoutout.ToString()); }
internal abstract void WriteResponse(HttpRequest req);