HttpProductInfoHeaderValueCollection HttpProductInfoHeaderValueCollection HttpProductInfoHeaderValueCollection HttpProductInfoHeaderValueCollection HttpProductInfoHeaderValueCollection Class

Definition

Represents the value of the User-Agent HTTP header on an HTTP request.

public : sealed class HttpProductInfoHeaderValueCollection : IStringable
struct winrt::Windows::Web::Http::Headers::HttpProductInfoHeaderValueCollection : IStringable
public sealed class HttpProductInfoHeaderValueCollection : IStringable
Public NotInheritable Class HttpProductInfoHeaderValueCollection Implements IStringable
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following sample code shows a method to get and set the User-Agent HTTP header on an HttpRequestMessage object using the properties and methods on the HttpProductInfoHeaderValueCollection and HttpProductInfoHeaderValue classes.


using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestUserAgent() {
            var request = new HttpRequestMessage();
            bool parsedOk = false;

            // Set the header with a string.
            parsedOk = request.Headers.UserAgent.TryParseAdd("testprogram/1.0");

            // Set the header with a strong type.
            request.Headers.UserAgent.Add(new HttpProductInfoHeaderValue("myprogram", "2.2"));

            // Get the strong type out 
            foreach (var value in request.Headers.UserAgent) {
                System.Diagnostics.Debug.WriteLine("One of the UserAgent values: {0} / {1}", value.Product.Name, value.Product.Version);
            }

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The UserAgent ToString() results: {0}", request.Headers.UserAgent.ToString());
        }

Remarks

The HttpProductInfoHeaderValueCollection represents the value of the User-Agent HTTP header on an HTTP request.

The HttpProductInfoHeaderValueCollection is a collection of HttpProductInfoHeaderValue objects used for product information in the HTTP User-Agent header.

The User-Agent header contains information about the user agent originating the request. The User-Agent header can contain multiple product tokens and comments identifying the user agent and any sub-products.

The UserAgent property on the HttpRequestHeaderCollection returns an HttpProductInfoHeaderValueCollection object.

Properties

Size Size Size Size Size

Gets the number of HttpProductInfoHeaderValue objects in the collection.

Methods

Append(HttpProductInfoHeaderValue) Append(HttpProductInfoHeaderValue) Append(HttpProductInfoHeaderValue) Append(HttpProductInfoHeaderValue) Append(HttpProductInfoHeaderValue)

Adds a new HttpProductInfoHeaderValue item to the end of the collection.

Clear() Clear() Clear() Clear() Clear()

Removes all objects from the collection.

First() First() First() First() First()

Retrieves an iterator to the first HttpProductInfoHeaderValue item in the collection.

GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Returns the HttpProductInfoHeaderValue at the specified index in the collection.

GetMany(UInt32, HttpProductInfoHeaderValue[]) GetMany(UInt32, HttpProductInfoHeaderValue[]) GetMany(UInt32, HttpProductInfoHeaderValue[]) GetMany(UInt32, HttpProductInfoHeaderValue[]) GetMany(UInt32, HttpProductInfoHeaderValue[])

Retrieves the HttpProductInfoHeaderValue items that start at the specified index in the collection.

GetView() GetView() GetView() GetView() GetView()

Returns an immutable view of the HttpProductInfoHeaderValueCollection.

IndexOf(HttpProductInfoHeaderValue, UInt32) IndexOf(HttpProductInfoHeaderValue, UInt32) IndexOf(HttpProductInfoHeaderValue, UInt32) IndexOf(HttpProductInfoHeaderValue, UInt32) IndexOf(HttpProductInfoHeaderValue, UInt32)

Retrieves the index of an HttpProductInfoHeaderValue in the collection.

InsertAt(UInt32, HttpProductInfoHeaderValue) InsertAt(UInt32, HttpProductInfoHeaderValue) InsertAt(UInt32, HttpProductInfoHeaderValue) InsertAt(UInt32, HttpProductInfoHeaderValue) InsertAt(UInt32, HttpProductInfoHeaderValue)

Inserts an HttpProductInfoHeaderValue into the collection at the specified index.

ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String)

Parses and adds an entry to the HttpProductInfoHeaderValueCollection.

RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32)

Removes the entry at the specified index from the HttpMethodHeaderValueCollection.

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last HttpProductInfoHeaderValue item from the collection.

ReplaceAll(HttpProductInfoHeaderValue[]) ReplaceAll(HttpProductInfoHeaderValue[]) ReplaceAll(HttpProductInfoHeaderValue[]) ReplaceAll(HttpProductInfoHeaderValue[]) ReplaceAll(HttpProductInfoHeaderValue[])

Replaces all the HttpProductInfoHeaderValue items in the collection with the specified HttpProductInfoHeaderValue items.

SetAt(UInt32, HttpProductInfoHeaderValue) SetAt(UInt32, HttpProductInfoHeaderValue) SetAt(UInt32, HttpProductInfoHeaderValue) SetAt(UInt32, HttpProductInfoHeaderValue) SetAt(UInt32, HttpProductInfoHeaderValue)

Sets the HttpProductInfoHeaderValue at the specified index in the collection.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpProductInfoHeaderValueCollection object.

TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String)

Tries to parse and add the specified item to the HttpProductInfoHeaderValueCollection.

See also