From 842eb702d2c9189270fd0c6fd4162cf4fa11f3ee Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Thu, 14 Nov 2024 21:03:47 +0100 Subject: [PATCH 01/10] setup Antiforgery --- build/trend-scenarios.yml | 5 +++ scenarios/antiforgery.benchmarks.yml | 32 +++++++++++++++++++ src/BenchmarksApps.sln | 20 +++++++++--- .../Antiforgery/Antiforgery.csproj | 9 ++++++ src/BenchmarksApps/Antiforgery/Program.cs | 11 +++++++ .../Properties/launchSettings.json | 12 +++++++ .../Antiforgery/appsettings.Development.json | 8 +++++ .../Antiforgery/appsettings.json | 9 ++++++ 8 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 scenarios/antiforgery.benchmarks.yml create mode 100644 src/BenchmarksApps/Antiforgery/Antiforgery.csproj create mode 100644 src/BenchmarksApps/Antiforgery/Program.cs create mode 100644 src/BenchmarksApps/Antiforgery/Properties/launchSettings.json create mode 100644 src/BenchmarksApps/Antiforgery/appsettings.Development.json create mode 100644 src/BenchmarksApps/Antiforgery/appsettings.json diff --git a/build/trend-scenarios.yml b/build/trend-scenarios.yml index f12136699..334c87041 100644 --- a/build/trend-scenarios.yml +++ b/build/trend-scenarios.yml @@ -91,6 +91,11 @@ parameters: - displayName: Json 10k arguments: --scenario json_middleware --variable singleStringJsonSize=10000 --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/json.benchmarks.yml --property scenario=Json10k +# Antiforgery + + - displayName: Antiforgery + arguments: --scenario antiforgery $(antiforgeryJobs) --load.connections 512 --property scenario=Antiforgery --property protocol=http + steps: - ${{ each s in parameters.scenarios }}: - task: PublishToAzureServiceBus@2 diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml new file mode 100644 index 000000000..c92306f67 --- /dev/null +++ b/scenarios/antiforgery.benchmarks.yml @@ -0,0 +1,32 @@ +imports: + - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Wrk/wrk.yml + - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.HttpClient/httpclient.yml + - https://github.com/aspnet/Benchmarks/blob/main/scenarios/aspnet.profiles.yml?raw=true + +variables: + serverPort: 5000 + serverScheme: http + +jobs: + antiforgerybenchmarks: + source: + repository: https://github.com/aspnet/benchmarks.git + branchOrCommit: main + project: src/BenchmarksApps/Antiforgery/Antiforgery.csproj + readyStateText: Application started. + variables: + singleStringJsonSize: 500 + arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}} + +scenarios: + + antiforgery: + application: + job: antiforgerybenchmarks + variables: + scenario: antiforgery + load: + job: wrk + variables: + path: /antiforgery + # presetHeaders: json diff --git a/src/BenchmarksApps.sln b/src/BenchmarksApps.sln index f4544e165..df1921ad0 100644 --- a/src/BenchmarksApps.sln +++ b/src/BenchmarksApps.sln @@ -64,6 +64,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunTemplate", "BenchmarksAp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Json", "BenchmarksApps\Json\Json.csproj", "{CEBEA47D-8154-4DC1-B071-6FAEAC448C88}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antiforgery", "BenchmarksApps\Antiforgery\Antiforgery.csproj", "{38AEFB02-3AE4-4E01-8FF9-FF09797C5853}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_Database|Any CPU = Debug_Database|Any CPU @@ -248,6 +250,14 @@ Global {CEBEA47D-8154-4DC1-B071-6FAEAC448C88}.Release_Database|Any CPU.Build.0 = Release_Database|Any CPU {CEBEA47D-8154-4DC1-B071-6FAEAC448C88}.Release|Any CPU.ActiveCfg = Release|Any CPU {CEBEA47D-8154-4DC1-B071-6FAEAC448C88}.Release|Any CPU.Build.0 = Release|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Debug_Database|Any CPU.ActiveCfg = Debug_Database|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Debug_Database|Any CPU.Build.0 = Debug_Database|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Release_Database|Any CPU.ActiveCfg = Release_Database|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Release_Database|Any CPU.Build.0 = Release_Database|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38AEFB02-3AE4-4E01-8FF9-FF09797C5853}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -255,13 +265,13 @@ Global GlobalSection(NestedProjects) = preSolution {8DF3A6BB-E8C5-4FAA-839A-D185C9F93CD5} = {D8A014FB-3C99-4831-9FFB-F4A89A48D8BD} {9E4AF835-2A78-4012-B0B5-9DA41ACDC716} = {D8A014FB-3C99-4831-9FFB-F4A89A48D8BD} - {20757830-EA66-4962-BDBB-A101A2062A2C} = {9E4AF835-2A78-4012-B0B5-9DA41ACDC716} - {07C0B18B-9738-4349-A8DF-3E88D3DF90AE} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} + {20757830-EA66-4962-BDBB-A101A2062A2C} = {D8A014FB-3C99-4831-9FFB-F4A89A48D8BD} + {07C0B18B-9738-4349-A8DF-3E88D3DF90AE} = {9E4AF835-2A78-4012-B0B5-9DA41ACDC716} {E68B58F8-40EA-49EA-A126-0B67F2BE7343} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} {ACA43671-AD28-4F72-AAAB-6C32B388C2F0} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} - {D8F11F87-823F-4864-926D-5F66448A5C13} = {398A40DA-FE1D-4B4D-A580-A33E29885553} - {3D2573DE-CE7A-4CB8-A980-8C8636EE059E} = {6A69DE6C-07A6-4ABE-A4D2-0F983A33BBF8} - {31B61CD7-4CF6-464F-B418-04C700A17CB9} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} + {D8F11F87-823F-4864-926D-5F66448A5C13} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} + {3D2573DE-CE7A-4CB8-A980-8C8636EE059E} = {398A40DA-FE1D-4B4D-A580-A33E29885553} + {31B61CD7-4CF6-464F-B418-04C700A17CB9} = {6A69DE6C-07A6-4ABE-A4D2-0F983A33BBF8} {D6616E03-A2DA-4929-AD28-595ECC4C004D} = {B6DB234C-8F80-4160-B95D-D70AFC444A3D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/BenchmarksApps/Antiforgery/Antiforgery.csproj b/src/BenchmarksApps/Antiforgery/Antiforgery.csproj new file mode 100644 index 000000000..1b28a01c8 --- /dev/null +++ b/src/BenchmarksApps/Antiforgery/Antiforgery.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs new file mode 100644 index 000000000..2ee7c9e12 --- /dev/null +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -0,0 +1,11 @@ +var builder = WebApplication.CreateBuilder(args); +builder.Logging.ClearProviders(); +var app = builder.Build(); + +app.UseAntiforgery(); + +await app.StartAsync(); + +Console.WriteLine("Application started."); + +await app.WaitForShutdownAsync(); \ No newline at end of file diff --git a/src/BenchmarksApps/Antiforgery/Properties/launchSettings.json b/src/BenchmarksApps/Antiforgery/Properties/launchSettings.json new file mode 100644 index 000000000..19830be77 --- /dev/null +++ b/src/BenchmarksApps/Antiforgery/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "Antiforgery": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:55471;http://localhost:55472" + } + } +} \ No newline at end of file diff --git a/src/BenchmarksApps/Antiforgery/appsettings.Development.json b/src/BenchmarksApps/Antiforgery/appsettings.Development.json new file mode 100644 index 000000000..1b2d3bafd --- /dev/null +++ b/src/BenchmarksApps/Antiforgery/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} \ No newline at end of file diff --git a/src/BenchmarksApps/Antiforgery/appsettings.json b/src/BenchmarksApps/Antiforgery/appsettings.json new file mode 100644 index 000000000..ec04bc120 --- /dev/null +++ b/src/BenchmarksApps/Antiforgery/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} \ No newline at end of file From 5bb977f46767d24d7dd51cf93601ed65d3fa4ddf Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Fri, 15 Nov 2024 00:40:12 +0100 Subject: [PATCH 02/10] fix the arguments of antiforgerybenchmarks --- scenarios/antiforgery.benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml index c92306f67..120c10c87 100644 --- a/scenarios/antiforgery.benchmarks.yml +++ b/scenarios/antiforgery.benchmarks.yml @@ -16,7 +16,7 @@ jobs: readyStateText: Application started. variables: singleStringJsonSize: 500 - arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}} + arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}}" scenarios: From e7c70915ddebff1ea91d5f48667d4912dc23fc16 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 15:28:45 +0100 Subject: [PATCH 03/10] add single endpoint for get and validate --- build/job-variables.yml | 2 ++ scenarios/antiforgery.benchmarks.yml | 1 - src/BenchmarksApps/Antiforgery/Program.cs | 25 ++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/build/job-variables.yml b/build/job-variables.yml index 975f4bd41..fcd6dbaaf 100644 --- a/build/job-variables.yml +++ b/build/job-variables.yml @@ -63,6 +63,8 @@ variables: value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/database.benchmarks.yml - name: jsonJobs value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/json.benchmarks.yml +- name: antiforgeryJobs + value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/antiforgery.benchmarks.yml - name: goldilocksJobs value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/goldilocks.benchmarks.yml - name: monoJobs diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml index 120c10c87..97b82f840 100644 --- a/scenarios/antiforgery.benchmarks.yml +++ b/scenarios/antiforgery.benchmarks.yml @@ -29,4 +29,3 @@ scenarios: job: wrk variables: path: /antiforgery - # presetHeaders: json diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index 2ee7c9e12..75384e84c 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -1,11 +1,26 @@ -var builder = WebApplication.CreateBuilder(args); -builder.Logging.ClearProviders(); +using Microsoft.AspNetCore.Antiforgery; + +var builder = WebApplication.CreateBuilder(); + +builder.Services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); + var app = builder.Build(); app.UseAntiforgery(); -await app.StartAsync(); +app.MapGet("/", () => Results.Ok("hello world!")); + +app.MapPost("/getAndValidateToken", async (HttpContext ctx, IAntiforgery antiforgery) => +{ + if (!ctx.Request.Cookies.ContainsKey("XSRF-TOKEN")) + { + var token = antiforgery.GetAndStoreTokens(ctx); + ctx.Response.Cookies.Append("XSRF-TOKEN", token.RequestToken!, new CookieOptions { HttpOnly = false }); + return Results.Ok(); + } -Console.WriteLine("Application started."); + await antiforgery.ValidateRequestAsync(ctx); + return Results.Ok(); +}); -await app.WaitForShutdownAsync(); \ No newline at end of file +app.Run(); \ No newline at end of file From be55a30fa9675c8f88a2b7fe9d8cbbbe9cde8b13 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 15:29:24 +0100 Subject: [PATCH 04/10] change the path --- scenarios/antiforgery.benchmarks.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml index 97b82f840..03eb0986c 100644 --- a/scenarios/antiforgery.benchmarks.yml +++ b/scenarios/antiforgery.benchmarks.yml @@ -1,4 +1,6 @@ -imports: +# usage: crank --config https://raw.githubusercontent.com/DeagleGross/Benchmarks/refs/heads/dmkorolev/antiforgery-sample/scenarios/antiforgery.benchmarks.yml --scenario antiforgery --profile aspnet-perf-win --application.source.branchOrCommit dmkorolev/antiforgery-sample --application.source.repository https://github.com/DeagleGross/Benchmarks.git + +imports: - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Wrk/wrk.yml - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.HttpClient/httpclient.yml - https://github.com/aspnet/Benchmarks/blob/main/scenarios/aspnet.profiles.yml?raw=true @@ -28,4 +30,4 @@ scenarios: load: job: wrk variables: - path: /antiforgery + path: /getAndValidateToken \ No newline at end of file From 8ea69c7eea9bf9464d7664733346fde7e7635d91 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 20:40:36 +0100 Subject: [PATCH 05/10] remove unneeded args --- build/trend-scenarios.yml | 2 +- scenarios/antiforgery.benchmarks.yml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/trend-scenarios.yml b/build/trend-scenarios.yml index 334c87041..e7d1a86ce 100644 --- a/build/trend-scenarios.yml +++ b/build/trend-scenarios.yml @@ -94,7 +94,7 @@ parameters: # Antiforgery - displayName: Antiforgery - arguments: --scenario antiforgery $(antiforgeryJobs) --load.connections 512 --property scenario=Antiforgery --property protocol=http + arguments: --scenario antiforgery $(antiforgeryJobs) --property scenario=Antiforgery steps: - ${{ each s in parameters.scenarios }}: diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml index 03eb0986c..c2743ca4a 100644 --- a/scenarios/antiforgery.benchmarks.yml +++ b/scenarios/antiforgery.benchmarks.yml @@ -16,9 +16,7 @@ jobs: branchOrCommit: main project: src/BenchmarksApps/Antiforgery/Antiforgery.csproj readyStateText: Application started. - variables: - singleStringJsonSize: 500 - arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}}" + # arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}}" scenarios: From b54ca534d59b32646c74693f5ca74f674947d7d6 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 20:45:14 +0100 Subject: [PATCH 06/10] change to GET --- src/BenchmarksApps/Antiforgery/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index 75384e84c..20bc245c0 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -10,7 +10,7 @@ app.MapGet("/", () => Results.Ok("hello world!")); -app.MapPost("/getAndValidateToken", async (HttpContext ctx, IAntiforgery antiforgery) => +app.MapGet("/getAndValidateToken", async (HttpContext ctx, IAntiforgery antiforgery) => { if (!ctx.Request.Cookies.ContainsKey("XSRF-TOKEN")) { From 4c75e17e941ff993fdab5c84f9282b5f5177dd59 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 21:27:04 +0100 Subject: [PATCH 07/10] use args for webapi build --- scenarios/antiforgery.benchmarks.yml | 2 +- src/BenchmarksApps/Antiforgery/Program.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scenarios/antiforgery.benchmarks.yml b/scenarios/antiforgery.benchmarks.yml index c2743ca4a..7c9b12d9f 100644 --- a/scenarios/antiforgery.benchmarks.yml +++ b/scenarios/antiforgery.benchmarks.yml @@ -16,7 +16,7 @@ jobs: branchOrCommit: main project: src/BenchmarksApps/Antiforgery/Antiforgery.csproj readyStateText: Application started. - # arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}}" + arguments: "--urls {{serverScheme}}://{{serverAddress}}:{{serverPort}}" scenarios: diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index 20bc245c0..e463c05f9 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Antiforgery; -var builder = WebApplication.CreateBuilder(); +var builder = WebApplication.CreateBuilder(args); +builder.Logging.ClearProviders(); builder.Services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); From 60ce9904fb366138c0281cbd6e55589a3485bb1d Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 21:34:59 +0100 Subject: [PATCH 08/10] we need logging to let crank know app started --- src/BenchmarksApps/Antiforgery/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index e463c05f9..1e99254ed 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Antiforgery; var builder = WebApplication.CreateBuilder(args); -builder.Logging.ClearProviders(); builder.Services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); From 2ab62175f794cc7974331ca2683fbe3c1ec8219c Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 22:14:54 +0100 Subject: [PATCH 09/10] enable http logging (tmp) --- src/BenchmarksApps/Antiforgery/Program.cs | 15 ++++++++++++++- src/BenchmarksApps/Antiforgery/appsettings.json | 9 ++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index 1e99254ed..888ee127e 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -1,11 +1,24 @@ using Microsoft.AspNetCore.Antiforgery; +using Microsoft.AspNetCore.HttpLogging; var builder = WebApplication.CreateBuilder(args); +builder.Logging.AddSimpleConsole(options => +{ + options.IncludeScopes = false; + options.TimestampFormat = "HH:mm:ss "; +}); + +builder.Services.AddHttpLogging(options => +{ + options.LoggingFields = HttpLoggingFields.RequestMethod | HttpLoggingFields.RequestPath | HttpLoggingFields.RequestHeaders; + options.CombineLogs = true; +}); -builder.Services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); +builder.Services.AddAntiforgery(options => options.HeaderName = "XSRF-TOKEN"); var app = builder.Build(); +app.UseHttpLogging(); app.UseAntiforgery(); app.MapGet("/", () => Results.Ok("hello world!")); diff --git a/src/BenchmarksApps/Antiforgery/appsettings.json b/src/BenchmarksApps/Antiforgery/appsettings.json index ec04bc120..8ec480ab0 100644 --- a/src/BenchmarksApps/Antiforgery/appsettings.json +++ b/src/BenchmarksApps/Antiforgery/appsettings.json @@ -2,7 +2,14 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Information" + }, + "Console": { + "FormatterOptions": { + "TimestampFormat": "HH:mm:ss ", + + } } }, "AllowedHosts": "*" From 7ecbcef487ab195759f2f24683b859eb2e11f1f8 Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Sat, 16 Nov 2024 22:37:36 +0100 Subject: [PATCH 10/10] log response headers and status --- src/BenchmarksApps/Antiforgery/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/BenchmarksApps/Antiforgery/Program.cs b/src/BenchmarksApps/Antiforgery/Program.cs index 888ee127e..91751c161 100644 --- a/src/BenchmarksApps/Antiforgery/Program.cs +++ b/src/BenchmarksApps/Antiforgery/Program.cs @@ -10,7 +10,14 @@ builder.Services.AddHttpLogging(options => { - options.LoggingFields = HttpLoggingFields.RequestMethod | HttpLoggingFields.RequestPath | HttpLoggingFields.RequestHeaders; + options.LoggingFields = + // request + HttpLoggingFields.RequestMethod + | HttpLoggingFields.RequestPath + | HttpLoggingFields.RequestHeaders + // response + | HttpLoggingFields.ResponseStatusCode + | HttpLoggingFields.ResponseHeaders; options.CombineLogs = true; });