HttpHeaderNames Class
Definition
- Assemblies
- Cuemon.Core.dll
Defines constants for well-known HTTP headers.
public static class HttpHeaderNames
- Inheritance
-
HttpHeaderNames
Examples
The following example demonstrates how to use
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Cuemon.Net.Http;
namespace MyApp.Examples;
public static class HttpHeaderNamesExample
{
public static async Task DemonstrateAsync()
{
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://example.com");
// Set request headers using the constants
request.Headers.Add(HttpHeaderNames.Accept, "application/json");
request.Headers.Add(HttpHeaderNames.Authorization, "Bearer token123");
request.Headers.Add(HttpHeaderNames.UserAgent, "MyApp/1.0");
request.Headers.Add(HttpHeaderNames.AcceptEncoding, "gzip");
Console.WriteLine("Request headers configured:");
foreach (var header in request.Headers)
{
Console.WriteLine($" {header.Key}: {string.Join(", ", header.Value)}");
}
}
}
Remarks
This is primarily a statement to the (IMO) bad design decision that was made effective from .NET Core 3.0 and forward. Discussion: https://github.com/dotnet/aspnetcore/issues/9514
Fields
| Name | Description |
|---|---|
| Accept | The |
| AcceptCharset | The |
| AcceptEncoding | The |
| AcceptLanguage | The |
| AcceptRanges | The |
| AccessControlAllowCredentials | The |
| AccessControlAllowHeaders | The |
| AccessControlAllowMethods | The |
| AccessControlAllowOrigin | The |
| AccessControlExposeHeaders | The |
| AccessControlMaxAge | The |
| AccessControlRequestHeaders | The |
| AccessControlRequestMethod | The |
| Age | The |
| Allow | The |
| Authorization | The |
| CacheControl | The |
| Connection | The |
| ContentDisposition | The |
| ContentEncoding | The |
| ContentLanguage | The |
| ContentLength | The |
| ContentLocation | The |
| ContentMD5 | The |
| ContentRange | The |
| ContentSecurityPolicy | The |
| ContentSecurityPolicyReportOnly | The |
| ContentType | The |
| Cookie | The |
| Date | The |
| ETag | The |
| Expect | The |
| Expires | The |
| Forwarded | The |
| From | The |
| Host | The |
| Http2Settings | The |
| IfMatch | The |
| IfModifiedSince | The |
| IfNoneMatch | The |
| IfRange | The |
| IfUnmodifiedSince | The |
| LastModified | The |
| Location | The |
| MaxForwards | The |
| Origin | The |
| Pragma | The |
| Prefer | The |
| ProxyAuthenticate | The |
| ProxyAuthorization | The |
| Range | The |
| Referer | The |
| RetryAfter | The |
| Server | The |
| ServerTiming | The |
| SetCookie | The |
| StrictTransportSecurity | The |
| TE | The |
| Trailer | The |
| TransferEncoding | The |
| Upgrade | The |
| UserAgent | The |
| Vary | The |
| Via | The |
| WWWAuthenticate | The |
| Warning | The |
| XApiKey | The de facto standard |
| XCorrelationId | The de facto standard |
| XCsrfToken | The de facto standard |
| XForwardedFor | The de facto standard |
| XForwardedHost | The de facto standard |
| XForwardedProto | The de facto standard |
| XRequestId | The de facto standard |