Skip to content

IHttpClientDefaultHeaders

NexusLabs.Needlr.Generators

IHttpClientDefaultHeaders Interface

Capability interface declaring that a named HttpClient options type configures arbitrary default request headers. When implemented, the source generator emits a foreach loop into the generated AddHttpClient callback that calls client.DefaultRequestHeaders.Add(kvp.Key, kvp.Value) for each entry, guarded by a null check on the dictionary.

public interface IHttpClientDefaultHeaders

Derived
IStandardHttpClientOptions

Remarks

Use this for headers that are safe to treat as Add (not TryAddWithoutValidation). The User-Agent header specifically should be expressed via IHttpClientUserAgent because it uses a different setter (UserAgent.ParseAdd).

Properties

IHttpClientDefaultHeaders.DefaultHeaders Property

Gets the default request headers to add to the generated HttpClient, or null to leave the defaults unchanged.

System.Collections.Generic.IReadOnlyDictionary<string,string>? DefaultHeaders { get; }

Property Value

System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>