|
| 1 | +--- |
| 2 | +title: "Effinitive" |
| 3 | +toc: false |
| 4 | +breadcrumbs: false |
| 5 | +--- |
| 6 | + |
| 7 | +**Language:** C# · [View source on GitHub](https://github.com/MDA2AV/Http11Probe/tree/main/src/Servers/EffinitiveServer) |
| 8 | + |
| 9 | +## Dockerfile |
| 10 | + |
| 11 | +```dockerfile |
| 12 | +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build |
| 13 | +WORKDIR /src |
| 14 | +COPY Directory.Build.props . |
| 15 | +COPY src/Servers/EffinitiveServer/ src/Servers/EffinitiveServer/ |
| 16 | +RUN dotnet restore src/Servers/EffinitiveServer/EffinitiveServer.csproj |
| 17 | +RUN dotnet publish src/Servers/EffinitiveServer/EffinitiveServer.csproj -c Release -o /app --no-restore |
| 18 | + |
| 19 | +FROM mcr.microsoft.com/dotnet/runtime:10.0 |
| 20 | +WORKDIR /app |
| 21 | +COPY --from=build /app . |
| 22 | +ENTRYPOINT ["dotnet", "EffinitiveServer.dll", "8080"] |
| 23 | +``` |
| 24 | + |
| 25 | +## Source — `Program.cs` |
| 26 | + |
| 27 | +```csharp |
| 28 | +using System.Text; |
| 29 | +using EffinitiveFramework.Core; |
| 30 | +using EffinitiveFramework.Core.Http; |
| 31 | + |
| 32 | +var port = args.Length > 0 && int.TryParse(args[0], out var p) ? p : 8080; |
| 33 | + |
| 34 | +var app = EffinitiveApp |
| 35 | + .Create() |
| 36 | + .UsePort(port) |
| 37 | + .MapEndpoints() |
| 38 | + .Build(); |
| 39 | + |
| 40 | +Console.WriteLine($"Effinitive listening on http://localhost:{port}"); |
| 41 | +await app.RunAsync(); |
| 42 | + |
| 43 | +// ── GET / ────────────────────────────────────────────────────── |
| 44 | +
|
| 45 | +sealed class GetRoot : NoRequestEndpointBase<string> |
| 46 | +{ |
| 47 | + protected override string Method => "GET"; |
| 48 | + protected override string Route => "/"; |
| 49 | + protected override string ContentType => "text/plain"; |
| 50 | + |
| 51 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 52 | + => ValueTask.FromResult("OK"); |
| 53 | +} |
| 54 | + |
| 55 | +// ── POST / ───────────────────────────────────────────────────── |
| 56 | +
|
| 57 | +sealed class PostRoot : NoRequestEndpointBase<string> |
| 58 | +{ |
| 59 | + protected override string Method => "POST"; |
| 60 | + protected override string Route => "/"; |
| 61 | + protected override string ContentType => "text/plain"; |
| 62 | + |
| 63 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 64 | + { |
| 65 | + var body = HttpContext?.Body; |
| 66 | + return ValueTask.FromResult(body is { Length: > 0 } ? Encoding.UTF8.GetString(body) : ""); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +// ── GET/POST /echo ──────────────────────────────────────────── |
| 71 | +
|
| 72 | +sealed class EchoGet : NoRequestEndpointBase<string> |
| 73 | +{ |
| 74 | + protected override string Method => "GET"; |
| 75 | + protected override string Route => "/echo"; |
| 76 | + protected override string ContentType => "text/plain"; |
| 77 | + |
| 78 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 79 | + => ValueTask.FromResult(Helpers.EchoHeaders(HttpContext)); |
| 80 | +} |
| 81 | + |
| 82 | +sealed class EchoPost : NoRequestEndpointBase<string> |
| 83 | +{ |
| 84 | + protected override string Method => "POST"; |
| 85 | + protected override string Route => "/echo"; |
| 86 | + protected override string ContentType => "text/plain"; |
| 87 | + |
| 88 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 89 | + => ValueTask.FromResult(Helpers.EchoHeaders(HttpContext)); |
| 90 | +} |
| 91 | + |
| 92 | +// ── GET/POST /cookie ────────────────────────────────────────── |
| 93 | +
|
| 94 | +sealed class CookieGet : NoRequestEndpointBase<string> |
| 95 | +{ |
| 96 | + protected override string Method => "GET"; |
| 97 | + protected override string Route => "/cookie"; |
| 98 | + protected override string ContentType => "text/plain"; |
| 99 | + |
| 100 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 101 | + => ValueTask.FromResult(Helpers.ParseCookies(HttpContext)); |
| 102 | +} |
| 103 | + |
| 104 | +sealed class CookiePost : NoRequestEndpointBase<string> |
| 105 | +{ |
| 106 | + protected override string Method => "POST"; |
| 107 | + protected override string Route => "/cookie"; |
| 108 | + protected override string ContentType => "text/plain"; |
| 109 | + |
| 110 | + public override ValueTask<string> HandleAsync(CancellationToken ct = default) |
| 111 | + => ValueTask.FromResult(Helpers.ParseCookies(HttpContext)); |
| 112 | +} |
| 113 | + |
| 114 | +// ── Shared helpers ──────────────────────────────────────────── |
| 115 | +
|
| 116 | +static class Helpers |
| 117 | +{ |
| 118 | + public static string EchoHeaders(HttpRequest? ctx) |
| 119 | + { |
| 120 | + if (ctx?.Headers is null) return ""; |
| 121 | + var sb = new StringBuilder(); |
| 122 | + foreach (var h in ctx.Headers) |
| 123 | + sb.Append(h.Key).Append(": ").Append(h.Value).Append("\r\n"); |
| 124 | + return sb.ToString(); |
| 125 | + } |
| 126 | + |
| 127 | + public static string ParseCookies(HttpRequest? ctx) |
| 128 | + { |
| 129 | + if (ctx is null) return ""; |
| 130 | + var sb = new StringBuilder(); |
| 131 | + foreach (var c in ctx.Cookies) |
| 132 | + sb.Append(c.Key).Append('=').Append(c.Value).Append("\r\n"); |
| 133 | + return sb.ToString(); |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +## Test Results |
| 139 | + |
| 140 | +<div id="server-summary"><p><em>Loading results...</em></p></div> |
| 141 | + |
| 142 | +### Compliance |
| 143 | + |
| 144 | +<div id="results-compliance"></div> |
| 145 | + |
| 146 | +### Smuggling |
| 147 | + |
| 148 | +<div id="results-smuggling"></div> |
| 149 | + |
| 150 | +### Malformed Input |
| 151 | + |
| 152 | +<div id="results-malformedinput"></div> |
| 153 | + |
| 154 | +### Caching |
| 155 | + |
| 156 | +<div id="results-capabilities"></div> |
| 157 | + |
| 158 | +### Cookies |
| 159 | + |
| 160 | +<div id="results-cookies"></div> |
| 161 | + |
| 162 | +<script src="/probe/data.js"></script> |
| 163 | +<script src="/probe/render.js"></script> |
| 164 | +<script> |
| 165 | +(function() { |
| 166 | + if (!window.PROBE_DATA) { |
| 167 | + document.getElementById('server-summary').innerHTML = '<p><em>No probe data available yet. Run the Probe workflow on <code>main</code> to generate results.</em></p>'; |
| 168 | + return; |
| 169 | + } |
| 170 | + ProbeRender.renderServerPage('Nginx'); |
| 171 | +})(); |
| 172 | +</script> |
0 commit comments