Skip to content

Consider adding more headers to HeaderNames #31374

Open

Description

@benaadams

Follow up to #31311 (comment)

List of HTTP header fields

With #31311 there are advantages to having items in the header list (single instance string).

This is most useful for request headers as they are always constructed strings; whereas response headers set in code are usually and interned string.

Non-exhaustive list of headers not currently included but are interesting:

Commonly used request headers:

public static readonly string XCorrelationId = "X-Correlation-ID";
public static readonly string XRequestId = "X-Request-ID";
public static readonly string XForwardedFor = "X-Forwarded-For";
public static readonly string XForwardedHost = "X-Forwarded-Host";
public static readonly string XForwardedProto = "X-Forwarded-Proto";

However if the server is also reverse-proxying/forwarding/routing between other servers; then response headers also become constructed strings (as they are parsed from the network). So that would then potentially include:

// Security header
public static readonly string ReferrerPolicy = "Referrer-Policy";
// Allow the browser to read cross origin timing values for the Resource Timing API
public static readonly string TimingAllowOrigin = "Timing-Allow-Origin";
// Ye olde "ASP.NET" header
public static readonly string XPoweredBy = "X-Powered-By";

Location is used for redirect; but sometimes Refresh is also used as a non-JS delay timed redirect (with interstitial)

public static readonly string Refresh = "Refresh";

Never seen; but rfc7240

public static readonly string Prefer = "Prefer";
public static readonly string PreferenceApplied = "Preference-Applied";

Activity

  1. kimsey0 commented on Feb 8, 2023

    @kimsey0
    Contributor

    Accept-CH (client hints, per RFC 8942) would be nice to add too.

  2. added
    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
    and removed on Aug 24, 2023
  3. MaRokas2005 commented on Jun 30, 2025

    @MaRokas2005

    Couldn't someone else write the code, and you would just need to confirm it? Because that would speed up the emergence of new header names. @martincostello

  4. MaRokas2005 commented on Jul 1, 2025

    @MaRokas2005

    Also you do not need 'X-' as prefix of custom header names. Link: don't need prefix '-'

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Perfarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions