unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.45k stars 175 forks source link

WithStaticFolder respone ContentLength in Header #537

Closed SolarisYan closed 2 years ago

SolarisYan commented 2 years ago

Describe the bug I use bellow code to create a static file webserver, because i just want this. It works fine, but i find that there's no ContentLength in the response, it's important for me, Anyone can help me, thanks a lot.

To Reproduce

        private static WebServer CreateStaticWebServer(string url, string filePath)
        {
            var server = new WebServer(
                    o => o
                        .WithUrlPrefix(url)
                        .WithMode(HttpListenerMode.EmbedIO))
                .WithLocalSessionManager()
                .WithStaticFolder(
                    "/",
                    filePath,
                    true,
                    m => m.WithContentCaching(false)
                 ).WithModule(
                    new ActionModule("/",
                                     HttpVerbs.Get,
                                     async ctx => await ctx.SendDataAsync(new { Message = "Error" })
                                    )
                );

            // Listen for state changes.
            server.StateChanged += (s, e) => $"WebServer New State - {e.NewState}".Info();

            return server;
        }

Expected behavior Respone with ContentLength in Header.

SolarisYan commented 2 years ago

use v2 have solved this issue