Skip to content

Commit

Permalink
test server
Browse files Browse the repository at this point in the history
  • Loading branch information
ladeak committed Sep 21, 2024
1 parent 2d1da1a commit 555cdf0
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CHttpServer/CHttpServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0-rc.1.24431.7" />
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions CHttpServer/HostExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace CHttpServer;

public static class HostExtensions
{
public static IWebHostBuilder UseCHttpServer(this IWebHostBuilder hostBuilder)
{
hostBuilder.ConfigureServices(services =>
{
services.TryAddSingleton<IConnectionListenerFactory, SocketTransportFactory>();
//services.AddSingleton<IHttpsConfigurationService, HttpsConfigurationService>();
//services.AddSingleton<HttpsConfigurationService.IInitializer, HttpsConfigurationService.Initializer>();
//services.AddSingleton<IServer, KestrelServerImpl>();
});
return hostBuilder;
}
}
18 changes: 18 additions & 0 deletions Http3Tools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CHttpExecutor", "src\CHttpE
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CHttpExecutor.Tests", "tests\CHttpExecutor.Tests\CHttpExecutor.Tests.csproj", "{5D24AD8A-FFE0-4023-B7FE-02811336F946}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{3058D078-6005-44F8-929D-C42CF343903D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCHttpServerApplication", "src\CHttpServer\TestCHttpServerApplication\TestCHttpServerApplication.csproj", "{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CHttpServer", "CHttpServer\CHttpServer.csproj", "{4F942742-1A61-4B96-B798-B37162375355}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,10 +75,22 @@ Global
{5D24AD8A-FFE0-4023-B7FE-02811336F946}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D24AD8A-FFE0-4023-B7FE-02811336F946}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D24AD8A-FFE0-4023-B7FE-02811336F946}.Release|Any CPU.Build.0 = Release|Any CPU
{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9}.Release|Any CPU.Build.0 = Release|Any CPU
{4F942742-1A61-4B96-B798-B37162375355}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F942742-1A61-4B96-B798-B37162375355}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F942742-1A61-4B96-B798-B37162375355}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F942742-1A61-4B96-B798-B37162375355}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AC32247C-B8A0-4ECE-BA5B-F197AC8042F9} = {3058D078-6005-44F8-929D-C42CF343903D}
{4F942742-1A61-4B96-B798-B37162375355} = {3058D078-6005-44F8-929D-C42CF343903D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E8352F3F-FBF3-4E2C-AEE3-5E03AF2BEAE3}
EndGlobalSection
Expand Down
32 changes: 32 additions & 0 deletions src/CHttpServer/TestCHttpServerApplication/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

// Configure the HTTP request pipeline.

app.UseHttpsRedirection();

var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
});

app.Run();

internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5177",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:7297;http://localhost:5177",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\CHttpServer\CHttpServer.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/CHttpServer/TestCHttpServerApplication/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

0 comments on commit 555cdf0

Please sign in to comment.