HttpServer, HttpProcessor and IHttpHandler.
This commit is contained in:
39
VAR.HttpServer.MiniServerTest/Program.cs
Normal file
39
VAR.HttpServer.MiniServerTest/Program.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace VAR.HttpServer.MiniServerTest
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
HttpServer httpServer = new HttpServer
|
||||
{
|
||||
Port = 3000,
|
||||
Handler = new HelloWorldHttpHandler(),
|
||||
LogDegugMessage = (msg) => Console.WriteLine("DEBUG: {0}", msg),
|
||||
LogException = (ex) =>
|
||||
{
|
||||
Console.WriteLine("!!!!! Exception !!!!");
|
||||
Console.WriteLine("Message: {0}", ex.Message);
|
||||
Console.WriteLine("StackTrace: {0}", ex.StackTrace);
|
||||
}
|
||||
};
|
||||
Console.Title = string.Format("MiniHTTPServer@{0}", httpServer.Port);
|
||||
Console.WriteLine("HTTP Server started on {0} port", httpServer.Port);
|
||||
httpServer.Start();
|
||||
|
||||
Process proc = Process.Start(string.Format("http://localhost:{0}", httpServer.Port));
|
||||
}
|
||||
|
||||
public class HelloWorldHttpHandler : IHttpHandler
|
||||
{
|
||||
public void HandleRequest(HttpProcessor p)
|
||||
{
|
||||
Console.WriteLine("Responding to {0}", p.Socket.Client.RemoteEndPoint);
|
||||
p.ResponseSuccess();
|
||||
p.OutputStream.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
VAR.HttpServer.MiniServerTest/Properties/AssemblyInfo.cs
Normal file
15
VAR.HttpServer.MiniServerTest/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("VAR.HttpServer.MiniServerTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("VAR")]
|
||||
[assembly: AssemblyProduct("VAR.HttpServer.MiniServerTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © VAR 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("6bd47b75-3dc2-4559-9311-e3d8117d4a89")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6BD47B75-3DC2-4559-9311-E3D8117D4A89}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>VAR.HttpServer.MiniServerTest</RootNamespace>
|
||||
<AssemblyName>VAR.HttpServer.MiniServerTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VAR.HttpServer\VAR.HttpServer.csproj">
|
||||
<Project>{e865ba90-11f7-46d4-b718-a536b0b76c35}</Project>
|
||||
<Name>VAR.HttpServer</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user