protected override void handleGETRequest(HttpProcessor p) { string url = ((FileResponderData)responderData).FilePath.String; Stream fs = File.Open(url, FileMode.Open); string mimetype; if (!url.Contains('.')) { mimetype = InputTypes.GetMimeType(null); } else { mimetype = InputTypes.GetMimeType(url.Substring(url.IndexOf('.'))); } p.writeSuccess(mimetype); fs.CopyTo(p.outputStream.BaseStream); fs.Close(); p.outputStream.BaseStream.Flush(); p.outputStream.Flush(); p.outputStream = null; }
protected override void handleGETRequest(HttpProcessor p) { string url = ((DirectoryResponderData)responderData).DirectoryPath.String + ((DirectoryRequestData)requestData).GetLocalUrl(p.GetUrl()); Console.WriteLine("Directory server returning " + url); if (File.Exists(url)) { Stream fs = File.Open(url, FileMode.Open, FileAccess.Read); string mimetype; if (!url.Contains('.')) { mimetype = InputTypes.GetMimeType(null); } else { mimetype = InputTypes.GetMimeType(url.Substring(url.IndexOf('.'))); } p.writeSuccess(mimetype); fs.CopyTo(p.outputStream.BaseStream); fs.Close(); p.outputStream.BaseStream.Flush(); } else if (url.EndsWith("favicon.ico")) { Stream fs = File.Open("q.ico", FileMode.Open, FileAccess.Read); p.writeSuccess("image/x-icon"); fs.CopyTo(p.outputStream.BaseStream); fs.Close(); p.outputStream.BaseStream.Flush(); } else { p.writeSuccess(); Console.WriteLine("Sent 404"); p.outputStream.Write("Nooo"); } p.outputStream.Flush(); p.outputStream = null; }