public override void DoGet(HttpRequest req, HttpResponse res)
        {
            String path     = req.GetQueryParameter("path");
            String fileName = Utilities.GetFileName(path);
            Stream stream   = FileManager.DownloadFile(path);

            res.Headers.Add("Content-Type", MIMETypes.GetContentType(path));
            res.Headers.Add("Content-Disposition", $"inline; filename = \"{fileName}\"");
            res.Headers.Add("Content-Length", stream.Length.ToString());
            res.Content = stream;
        }
示例#2
0
        public void Process(HttpRequest req, HttpResponse res)
        {
            res.Headers.Add("Location", _path);
            res.Headers.Add("Content-Type", MIMETypes.GetContentType(_path));

            Stream content;

            try
            {
                content = new StreamReader((_root + "/" + _path)).BaseStream;
            }
            catch
            {
                content = new MemoryStream();
            }
            res.Headers.Add("Content-Length", content.Length.ToString());
            res.Content = content;
        }