WebserverSettings is the primary configuration object for Watson 7. It controls host binding, protocol enablement, I/O behavior, TLS, default headers, access control, debug logging, Alt-Svc, and API-route timeouts.
Source of truth:
src/WatsonWebserver/Core/WebserverSettings.cssrc/WatsonWebserver/Core/Settings/ProtocolSettings.cssrc/WatsonWebserver/Core/Settings/AltSvcSettings.cssrc/WatsonWebserver/Core/Settings/TimeoutSettings.cssrc/WatsonWebserver/Core/Settings/*
using WatsonWebserver;
using WatsonWebserver.Core;
WebserverSettings settings = new WebserverSettings("127.0.0.1", 9000, false);
settings.Protocols.EnableHttp1 = true;
settings.Protocols.EnableHttp2 = false;
settings.Protocols.EnableHttp3 = false;
Webserver server = new Webserver(settings, DefaultRoute);The hostname or bind target Watson should listen on.
Default:
"localhost"
Validation:
- throws if set to
nullor empty
Notes:
"*"and"+"forceUseMachineHostname = true- the constructor normalizes
"::"to"[::]"
The TCP port to listen on.
Default:
8000
Validation:
- throws if less than
0
Practical note:
- use normal TCP port ranges;
0is not rejected by the property, but typical consumer code should use an explicit port
Computed property returning:
http://[hostname]:[port]/- or
https://[hostname]:[port]/whenSsl.Enableistrue
This is derived from Hostname, Port, and Ssl.Enable.
Nested ProtocolSettings controlling HTTP/1.1, HTTP/2, and HTTP/3 behavior.
Default:
- non-null
ProtocolSettingsinstance
Validation:
- throws if set to
null
Nested AltSvcSettings controlling HTTP/3 advertisement.
Default:
- non-null
AltSvcSettingsinstance
Validation:
- throws if set to
null
Nested IOSettings controlling stream buffer sizing, body/header limits, keep-alive, and HTTP/1.1-specific pooling/caching.
Default:
- non-null
IOSettingsinstance
Validation:
- throws if set to
null
Nested SslSettings controlling TLS enablement and certificate loading.
Default:
- non-null
SslSettingsinstance
Validation:
- throws if set to
null
Nested HeaderSettings controlling default response headers.
Default:
- non-null
HeaderSettingsinstance
Validation:
- throws if set to
null
AccessControlManager controlling default permit/deny behavior and allow/deny matchers.
Default:
DefaultPermit
Validation:
- throws if set to
null
Nested DebugSettings controlling debug logging categories.
Default:
- non-null
DebugSettingsinstance
Validation:
- throws if set to
null
Nested TimeoutSettings controlling API-route request timeouts.
Default:
- non-null
TimeoutSettingsinstance
Validation:
- throws if set to
null
Nested TelemetrySettings controlling metric and trace emission, forwarded-header client-address resolution, and the optional in-process Prometheus scrape endpoint. See TelemetrySettings.
Default:
- non-null
TelemetrySettingsinstance
Validation:
- throws if set to
null
When true, Watson uses the machine hostname instead of the literal Hostname value for relevant host metadata behavior.
Default:
false
Special behavior:
- if
Hostnameis"*"or"+", this behaves astrueregardless of the assigned value
Creates a settings object with the built-in defaults.
Common convenience constructor.
Behavior:
- null or empty
hostnamebecomes"localhost" port < 0throws"::"becomes"[::]"Ssl.Enableis set fromssl
File:
src/WatsonWebserver/Core/Settings/ProtocolSettings.cs
Default:
true
Default:
false
Default:
false
Enables h2c prior-knowledge mode.
Default:
false
Important:
- this is explicit opt-in
- Watson validates unsupported combinations at startup
Maximum concurrent streams per connection.
Default:
100
Validation:
- throws if less than
1
Backed by:
Protocols.Http2.MaxConcurrentStreams
Nested Http2Settings.
Validation:
- throws if set to
null
Nested Http3Settings.
Validation:
- throws if set to
null
Idle connection timeout in milliseconds.
Default:
120000
Validation:
- throws if less than
1000
File:
src/WatsonWebserver/Core/Http2/Http2Settings.cs
HPACK dynamic table size.
Default:
Http2Constants.DefaultHeaderTableSize
Default:
false
Default:
100
Default:
Http2Constants.DefaultInitialWindowSize
Validation:
- throws if less than
0 - throws if greater than
Http2Constants.MaxInitialWindowSize
Default:
Http2Constants.DefaultMaxFrameSize
Validation:
- throws if outside the HTTP/2 min/max frame size bounds
Default:
Http2Constants.DefaultMaxHeaderListSize
File:
src/WatsonWebserver/Core/Http3/Http3Settings.cs
Default:
0
Validation:
- throws if less than
0
Default:
0
Validation:
- throws if less than
0
Default:
0
Validation:
- throws if less than
0
Whether RFC 9220 datagrams are advertised.
Default:
false
File:
src/WatsonWebserver/Core/Settings/AltSvcSettings.cs
Default:
false
Important:
- only meaningful when HTTP/3 is enabled and usable
Optional advertised authority override.
Default:
null
Advertised Alt-Svc port.
Default:
0
Meaning:
0means use the primary server port
Validation:
- throws if less than
0 - throws if greater than
65535
Default:
"h3"
Default:
86400
Validation:
- throws if less than
0
File:
src/WatsonWebserver/Core/Settings/IOSettings.cs
Nested Http1IOSettings.
Validation:
- throws if set to
null
Default:
65536
Validation:
- throws if less than
1
Maximum concurrent requests.
Default:
1024
Validation:
- throws if less than
1
Inbound socket read timeout in milliseconds.
Default:
10000
Validation:
- throws if less than
1
Maximum incoming header size in bytes.
Default:
65536
Validation:
- throws if less than
1
Default:
false
Maximum request body size in bytes.
Default:
0
Meaning:
0or less disables this check
Note:
- enforced against declared request body sizes before reading
Maximum number of request headers.
Default:
64
Meaning:
0or less disables this check
File:
src/WatsonWebserver/Core/Settings/Http1IOSettings.cs
These settings exist to control HTTP/1.1-specific retention and cache behavior without cluttering Settings.IO.
Maximum retained pooled objects per HTTP/1.1 pooled type.
Default:
256
Clamp:
- minimum
0 - maximum
4096
Meaning:
0disables HTTP/1.1 pooled retention
Maximum cached HTTP/1.1 response-header template entries.
Default:
256
Clamp:
- minimum
0 - maximum
2048
Meaning:
0disables the cache
Maximum cached HTTP/1.1 status-line entries.
Default:
64
Clamp:
- minimum
0 - maximum
256
Meaning:
0disables the cache
File:
src/WatsonWebserver/Core/Settings/SslSettings.cs
Default:
false
Directly assigned X509Certificate2.
Behavior:
- if not explicitly set, Watson attempts to load from
PfxCertificateFile - loading occurs lazily when the property is accessed
Default:
null
Default:
null
Default:
false
Default:
true
Note:
- the property name is currently spelled
AcceptInvalidAcertificatesin code
File:
src/WatsonWebserver/Core/Settings/HeaderSettings.cs
Default:
true
Headers added to responses unless already set.
Default keys:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: OPTIONS, HEAD, GET, PUT, POST, DELETE, PATCHAccess-Control-Allow-Headers: *Access-Control-Expose-Headers:Accept: */*Accept-Language: en-US, enAccept-Charset: ISO-8859-1, utf-8Cache-Control: no-cacheConnection: closeHost: localhost:8000
Setter behavior:
- assigning
nullrestores the built-in defaults
File:
src/WatsonWebserver/Core/Settings/DebugSettings.cs
All debug flags default to false.
Logs access-control behavior.
Logs routing behavior.
Logs request handling.
Logs response handling.
Important:
- set
server.Events.Loggerif you want to receive debug output
Files:
src/WatsonWebserver/Core/AccessControlManager.cssrc/WatsonWebserver/Core/AccessControlMode.cs
Default:
AccessControlMode.DefaultPermit
Modes:
DefaultPermit: allow unless explicitly deniedDefaultDeny: deny unless explicitly permitted
IpMatcher.Matcher used when Mode is DefaultDeny.
Setter behavior:
- assigning
nullreplaces it with an empty matcher
IpMatcher.Matcher used when Mode is DefaultPermit.
Setter behavior:
- assigning
nullreplaces it with an empty matcher
Evaluates an IP address against the configured mode and matchers.
Validation:
- throws if
ipisnullor empty
File:
src/WatsonWebserver/Core/Settings/TimeoutSettings.cs
Default:
TimeSpan.Zero
Meaning:
TimeSpan.Zerodisables API-route request timeouts- positive values enable timeout cancellation and 408 behavior on API routes
Validation:
- throws if less than
TimeSpan.Zero
WebserverSettings settings = new WebserverSettings("127.0.0.1", 8080);
settings.Protocols.EnableHttp1 = true;
settings.Protocols.EnableHttp2 = false;
settings.Protocols.EnableHttp3 = false;WebserverSettings settings = new WebserverSettings("localhost", 8443, true);
settings.Ssl.PfxCertificateFile = "server.pfx";
settings.Ssl.PfxCertificatePassword = "password";
settings.Protocols.EnableHttp1 = true;
settings.Protocols.EnableHttp2 = true;WebserverSettings settings = new WebserverSettings("localhost", 8443, true);
settings.Ssl.PfxCertificateFile = "server.pfx";
settings.Ssl.PfxCertificatePassword = "password";
settings.Protocols.EnableHttp1 = true;
settings.Protocols.EnableHttp2 = true;
settings.Protocols.EnableHttp3 = true;
settings.AltSvc.Enabled = true;
settings.AltSvc.Http3Alpn = "h3";
settings.AltSvc.MaxAgeSeconds = 86400;WebserverSettings settings = new WebserverSettings("127.0.0.1", 8080);
settings.Timeout.DefaultTimeout = TimeSpan.FromSeconds(30);WebserverSettings settings = new WebserverSettings("127.0.0.1", 8080);
settings.IO.Http1.PoolMaxRetainedPerType = 256;
settings.IO.Http1.ResponseHeaderTemplateCacheSize = 256;
settings.IO.Http1.StatusLineCacheSize = 64;WebserverSettings settings = new WebserverSettings("0.0.0.0", 8080);
settings.AccessControl.Mode = AccessControlMode.DefaultDeny;
settings.AccessControl.PermitList.Add("192.168.1.0", "255.255.255.0");Controls the metrics and traces Watson emits and how the span resolves the client address. Watson
emits through a Meter and ActivitySource (both named Watson by default); a host subscribes by
name. Emission is a near-zero-cost no-op when nothing is listening.
Master switch. When false, Watson skips all metric and trace emission before any tag work.
Default:
true
Meter name a metrics host subscribes to. Treat as a stable contract.
Default:
Watson
Validation:
- throws if set to
nullor empty
Activity source name a trace host subscribes to. Treat as a stable contract.
Default:
Watson
Validation:
- throws if set to
nullor empty
Enables the metric instruments.
Default:
true
Enables the per-request Server span.
Default:
true
Adopt an inbound W3C trace context (traceparent/tracestate) as the span's parent.
Default:
true
Record the request and response body-size metrics and span attributes.
Default:
true
Stamp the normalized request and response media type on the span.
Default:
true
Record WebSocket session and handshake metrics.
Default:
true
Attach an exception span event on failure.
Default:
true
Resolve the span's client.address from a forwarded header instead of the raw socket peer. Leave off
on internet-facing listeners; enable only behind a known proxy declared in TrustedProxies. Affects
span attributes only, never a security decision.
Default:
false
Header carrying the client-chain IP list.
Default:
X-Forwarded-For
Validation:
- throws if set to
nullor empty
Header carrying the client-visible scheme, used to override url.scheme when the request is trusted.
Default:
X-Forwarded-Proto
Validation:
- throws if set to
nullor empty
IpMatcher.Matcher allow-list of proxies permitted to set forwarded headers. When empty, only the
nearest hop is trusted.
Default:
- empty
Matcher
Maximum trusted proxy hops to walk when resolving the client address.
Default:
1(clamped to a minimum of0)
Nested TelemetryPrometheusSettings for the optional in-process scrape endpoint. The endpoint is
served on the existing Watson listener, so it opens no additional port and cannot create a listener
port conflict.
Prometheus.Enable— enable the endpoint. Defaultfalse.Prometheus.Path— path at which the endpoint is served. Default/metrics; always begins with/.
WebserverSettings settings = new WebserverSettings("127.0.0.1", 8080);
settings.Telemetry.Prometheus.Enable = true; // served at /metrics on the main listener
settings.Telemetry.TrustForwardedHeaders = true; // resolve client.address behind a proxy
settings.Telemetry.TrustedProxies.Add("10.0.0.0", "255.0.0.0");WebserverSettingsis validated at startup; not every invalid protocol combination is rejected at property-assignment time- HTTP/3 requires TLS and runtime QUIC support
- HTTP/2 cleartext requires explicit prior-knowledge enablement
- wildcard hosts (
*and+) forceUseMachineHostname Watsonconsumers configureWebserverSettingsthrough theWatsonpackage; theWatsonWebserver.Corenamespace contains the shared settings types and abstractions