WarningHeaderValue Class

Represents the value of the Warning HTTP header.

Assembly: System.Net.Http.Formatting.dll

Syntax

public sealed class WarningHeaderValue

Remarks

The Warning header provides a way to indicate that the client, a proxy, or a gateway has made a modification to the message which is likely to be important to the user or another system.

The WarningHeaderValue class provides a convenient way to parse and construct Warning header values according to RFC 7234.

Constructors

Properties

Methods

Example

The following example demonstrates how to create and add a WarningHeaderValue to an HTTP request.

using System; using System.Net.Http; using System.Net.Http.Headers; public class Example { public static void Main() { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com"); // Create a WarningHeaderValue var warning = new WarningHeaderValue("my-agent", 110, "Response is stale"); request.Headers.Warning.Add(warning); // You can also include a date var warningWithDate = new WarningHeaderValue("another-agent", 199, "Content modified", DateTimeOffset.UtcNow); request.Headers.Warning.Add(warningWithDate); // Send the request... // var response = await client.SendAsync(request); // Console.WriteLine(response); } }