diff --git a/Unosquare.Labs.EmbedIO.Command/Options.cs b/Unosquare.Labs.EmbedIO.Command/Options.cs index 0636d9c2a..8440bb1b9 100644 --- a/Unosquare.Labs.EmbedIO.Command/Options.cs +++ b/Unosquare.Labs.EmbedIO.Command/Options.cs @@ -18,6 +18,9 @@ internal class Options [OptionList('a', "api", Separator = ',', HelpText = "Specify assemblies to load, separated by a comma.")] public IList ApiAssemblies { get; set; } + [Option('v', "noverb", HelpText = "Output Web server info.", DefaultValue = false)] + public bool NoVerbose { get; set; } + [HelpOption] public string GetUsage() { diff --git a/Unosquare.Labs.EmbedIO.Command/Program.cs b/Unosquare.Labs.EmbedIO.Command/Program.cs index 1e7df40b5..283c4e650 100644 --- a/Unosquare.Labs.EmbedIO.Command/Program.cs +++ b/Unosquare.Labs.EmbedIO.Command/Program.cs @@ -24,7 +24,11 @@ private static void Main(string[] args) Console.WriteLine(" Command-Line Utility: Press any key to stop the server."); - using (var server = WebServer.CreateWithConsole("http://localhost:" + options.Port + "/")) + var serverUrl = "http://localhost:" + options.Port + "/"; + using ( + var server = options.NoVerbose + ? WebServer.Create(serverUrl) + : WebServer.CreateWithConsole(serverUrl)) { if (Properties.Settings.Default.UseLocalSessionModule) server.WithLocalSession(); diff --git a/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs b/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs index 39248af19..ff3330c95 100644 --- a/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs +++ b/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs @@ -254,4 +254,4 @@ public void Kill() WebServer.Dispose(); } } -} +} \ No newline at end of file diff --git a/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs b/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs index 4e501858b..ba3ac2005 100644 --- a/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs +++ b/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs @@ -6,6 +6,8 @@ public static class TestHelper { + public static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; + public const string BigDataFile = "bigdata.bin"; public const string SmallDataFile = "smalldata.bin"; diff --git a/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs b/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs index e1239fc05..20ba48da2 100644 --- a/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs +++ b/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs @@ -24,6 +24,11 @@ public void Init() [Test] public async void TestConnectWebSocket() { + if (TestHelper.IsMono) + { + Assert.Inconclusive("Mono doesn't have support to WebSockets"); + } + Assert.IsNotNull(WebServer.Module(), "WebServer has WebSocketsModule"); Assert.AreEqual(WebServer.Module().Handlers.Count, 1, "WebSocketModule has one handler"); diff --git a/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs b/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs index 39098d472..1f487541e 100644 --- a/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs +++ b/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs @@ -329,7 +329,15 @@ private bool HandleGet(HttpListenerContext context, WebServer server, bool sendB } context.Response.ContentLength64 = size; - context.Response.OutputStream.Write(buffer, lrange, (int) size); + + try + { + context.Response.OutputStream.Write(buffer, lrange, (int) size); + } + catch (HttpListenerException) + { + // Connection error, nothing else to do + } } else {