Represents a parser for Range condition headers (If-Range).
Namespace: System.Net.Http.Headers
Assembly: System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)
Inheritance: Object > RangeConditionHeaderParser
This class has no public methods.
This class has no public properties.
This class has no public constructors.
The RangeConditionHeaderParser class is responsible for parsing the value of the If-Range HTTP header. This header is used in conditional requests to specify that a resource should only be transferred if the server's version of the resource matches a given tag or date.
The parser handles two main types of If-Range header values:
"abcde12345" or W/"xyz789")."Tue, 15 Nov 1994 12:45:26 GMT").When parsing an If-Range header, this parser will attempt to interpret the value as either an ETag or a date. If successful, it will produce an appropriate object representing the condition.
Here's a simple example of how to use the parser (though typically it's used internally by the HTTP client/server stack):
var etagValue = "\"some-etag-value\"";
var dateValue = "Mon, 27 Sep 2021 17:00:00 GMT";
// In a real scenario, these would come from incoming HTTP headers
// and the parser would be invoked by the framework.
try {
// If-Range with ETag
var etagCondition = RangeConditionHeaderValue.Parse(etagValue);
Console.WriteLine($"Parsed ETag Condition: {etagCondition}");
// If-Range with Date
var dateCondition = RangeConditionHeaderValue.Parse(dateValue);
Console.WriteLine($"Parsed Date Condition: {dateCondition}");
} catch (FormatException ex) {
Console.WriteLine($"Error parsing header: {ex.Message}");
}
// Output might look like:
// Parsed ETag Condition: "some-etag-value"
// Parsed Date Condition: Mon, 27 Sep 2021 17:00:00 GMT