HttpHeaderParser
Namespace: System.Net
Assembly: System.Net.Http.dll
Description
Represents a base class for HTTP header parsers. This abstract class provides the fundamental parsing logic for HTTP header values. Concrete implementations are responsible for parsing specific header types according to their defined formats.
Usage
The HttpHeaderParser class is an abstract base class. You typically interact with its derived classes, such as ProductHeaderParser or DateTimeHeaderParser, to parse specific HTTP headers.
Example: Conceptual Parsing
While you don't instantiate HttpHeaderParser directly, you might see it used internally by .NET's HTTP client implementation.
// This is a conceptual illustration, not direct usage.
// A concrete parser like ProductHeaderParser might be used.
// Imagine a string representing a User-Agent header
string userAgentHeader = "MyCoolApp/1.0 (Windows NT 10.0; Win64; x64)";
// A hypothetical parser that handles product-based headers
// HttpHeaderParser parser = new ProductHeaderParser(); // Not directly instantiable
// In practice, you'd use methods on HttpRequestHeaders or HttpResponseHeaders
// which would leverage these internal parsers.
Methods
abstract bool TryParse(string value, out TValue parsedValue)abstract bool TryParseElement(string value, out TValue parsedValue)
Remarks
This class is part of the low-level HTTP header management in the .NET framework. It defines the contract for parsing strings into structured header values, ensuring consistent handling of various HTTP header formats.
Derived Classes
- ProductHeaderParser
- CacheControlHeaderParser
- RetryConditionHeaderManager (Manager for specific parsers)
- ...and others for various header types.
See Also
- HttpHeaderParser (This page)
- System.Net
- System.Net.Http