Skip to content

Instantly share code, notes, and snippets.

@eduherminio
Last active October 15, 2020 09:38
Show Gist options
  • Save eduherminio/0474767d21624366ea0a5e82c7a1d1f4 to your computer and use it in GitHub Desktop.
Save eduherminio/0474767d21624366ea0a5e82c7a1d1f4 to your computer and use it in GitHub Desktop.

Overriding Kestrel options

Default WireMock Kestrel server options

These are all available Kestrel server options and you can read here all available Kestrel server options limits and their default values.

WireMock overrides some of those Kestrel server options limits, i.e.

  • KestrelServerOptions.Limits.MaxRequestBodySize: unlimited.
  • KestrelServerOptions.Limits.MaxRequestBufferSize: unlimited.

You can check the variables that WireMock overrides by default here for .NET Standard 1.3 and here for .NET Standard > 1.3.

Overriding Kestrel server options yourself

WireMock also allows you to override those Kestrel server options and limits.

KestrelServerOptions can generally be overridden using a configuration provider, which expects them to follow the following structure:

{
  "Kestrel": {
    "Limits": {
      "MaxRequestBodySize": 30000000,
      "MaxRequestHeadersTotalSize": 32768
    },
    "DisableStringReuse": true
  }
}

The recommended, multi-platform way of defining nested environment variables is using __.

Examples:

  • You can override KestrelServerOptions.Limits.MaxRequestHeadersTotalSize by setting Kestrel__Limits__MaxRequestHeadersTotalSize environment variable to 65536.
  • You can override KestrelServerLimits.Http2.MaxRequestHeaderFieldSize by setting Kestrel__Limits__Http2__MaxRequestHeaderFieldSize environment variable to 16384.

Please bear in mind that:

  • Environment variable values take precedence over WireMock default overrides.
  • You can only override WireMock Kestrel options using environment variables, not configuration files.

You can find more information about Kestrel options and their configuration here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment