Пример #1
0
        public void SendResponse(HttpListenerRequest request, HttpListenerResponse response)
        {
            var stream = new FileLoader(request.Url.AbsolutePath).LoadStream();

            response.ContentLength64 = stream.Length;
            response.SendChunked = false;
            response.ContentType = request.ContentType;
            response.AddHeader("Content-disposition", "attachment; filename=" + request.RawUrl.Remove(0, 1));

            writeTo(stream, response.OutputStream);

            response.StatusCode = (int)HttpStatusCode.OK;
            response.StatusDescription = "OK";

            stream.Close();
            response.Close();

            Console.WriteLine("200");
        }