dotnet / dotnet/aspnetcore

Consider adding more headers to `HeaderNames`

Open
#31,374 4 comments 5 reactions 0 assignees View on GitHub
area-networking Perf
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

Follow up to https://github.com/dotnet/aspnetcore/pull/31311#discussion_r602945650

[List of HTTP header fields](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)

With https://github.com/dotnet/aspnetcore/pull/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:
```csharp
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:

```csharp
// 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)
```csharp
public static readonly string Refresh = "Refresh";
```
Never seen; but [rfc7240](https://tools.ietf.org/html/rfc7240)
```csharp
public static readonly string Prefer = "Prefer";
public static readonly string PreferenceApplied = "Preference-Applied";
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.