GetFirstHeader Method  
 

Begins enumeration of response headers returned from the last completed navigation and retrieves the first header name and value.

Syntax

object.GetFirstHeader( HeaderName, HeaderValue )

Parameters

HeaderName
A string buffer which will contain the name of the first header returned by the server.
HeaderValue
A string buffer which will contain the value of the first header returned by the server.

Return Value

Returns True if the method succeeds or False if the method fails.

Remarks

The response headers exposed by this method correspond to the most recent completed navigation for the specified browser instance. Callers typically use this method to start an enumeration and then call GetNextHeader repeatedly until it returns False to indicate there are no more headers to enumerate.

Header names are case-insensitive by definition. This method will usually return header names as lower-case values, but applications should never depend on the casing and should compare names case-insensitively. The header names and values are returned exactly as enumerated internally by the WebView2 control.

Some response headers can appear multiple times in a message. For list-valued headers (those defined by the HTTP specifications to be comma-joinable), the implementation may return a single entry with a comma-separated value (e.g., Accept-Language, Cache-Control, etc.). Other headers must not be combined; for example, each Set-Cookie header is returned as a separate name/value pair and will be seen multiple times during enumeration, each with a single cookie value. Code that depends on specific headers should be prepared for either a single combined value or multiple discrete occurrences of the same header name, depending on the header's semantics.

Enumeration reflects a snapshot of the headers for that response. Beginning a new navigation or calling ClearHeaders invalidates the current enumeration. Only one header enumeration can be active per browser instance at a time. This method cannot be called while the browser is in the process of navigating to a new location. It will also fail if the current document is a local file or if the document text was set dynamically using the DocumentText property. There are no response headers available in a local context.

See Also

ClearHeaders Method, GetHeader Method, GetNextHeader Method