HttpChallengeHeaderValueCollection
HttpChallengeHeaderValueCollection
HttpChallengeHeaderValueCollection
HttpChallengeHeaderValueCollection
Class
Definition
Represents the value of the Proxy-Authenticate or WWW-Authenticate HTTP header on an HTTP response.
public : sealed class HttpChallengeHeaderValueCollection : IIterable, IVector, IStringable, IHttpChallengeHeaderValueCollectionpublic sealed class HttpChallengeHeaderValueCollection : IEnumerable, IList, IStringable, IHttpChallengeHeaderValueCollectionPublic NotInheritable Class HttpChallengeHeaderValueCollection Implements IEnumerable, IList, IStringable, IHttpChallengeHeaderValueCollection// You can use this class in JavaScript.
- Attributes
| 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 Proxy-Authenticate HTTP header on an HttpResponseMessage object using the properties and methods on the HttpChallengeHeaderValueCollection and HttpChallengeHeaderValue classes.
using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
public void DemonstrateHeaderResponseProxyAuthenticate() {
var response = new HttpResponseMessage();
// Set the header with a strong type.
response.Headers.ProxyAuthenticate.TryParseAdd("Basic");
response.Headers.ProxyAuthenticate.Add(new HttpChallengeHeaderValue("authScheme", "authToken"));
// Get the strong type out
foreach (var value in response.Headers.ProxyAuthenticate) {
System.Diagnostics.Debug.WriteLine("Proxy authenticate scheme and token: {0} {1}", value.Scheme, value.Token);
}
// The ToString() is useful for diagnostics, too.
System.Diagnostics.Debug.WriteLine("The ProxyAuthenticate ToString() results: {0}", response.Headers.ProxyAuthenticate.ToString());
}
Remarks
The HttpChallengeHeaderValueCollection represents the value of the Proxy-Authenticate or WWW-Authenticate HTTP header on an HTTP response.
The HttpChallengeHeaderValueCollection provides a collection container for instances of the HttpChallengeHeaderValue class used for authentication information used in the Authorization, ProxyAuthorization, WWW-Authenticate, and Proxy-Authenticate HTTP header values.
The ProxyAuthenticate property on HttpResponseHeaderCollection returns an HttpChallengeHeaderValueCollection object. The WwwAuthenticate property on HttpResponseHeaderCollection also returns an HttpChallengeHeaderValueCollection object.
Collection member lists
For JavaScript, HttpChallengeHeaderValueCollection has the members shown in the member lists. In addition, HttpChallengeHeaderValueCollection supports members of Array.prototype and using an index to access items.
Enumerating the collection in C# or Microsoft Visual Basic
You can iterate through an HttpChallengeHeaderValueCollection object in C# or Microsoft Visual Basic. In many cases, such as using foreach syntax, the compiler does this casting for you and you won't need to cast to IEnumerable<HttpChallengeHeaderValue> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast the collection object to IEnumerable
Properties
Item[Int32] Item[Int32] Item[Int32] Item[Int32]
Gets or sets the element at the specified index.
This member is not implemented in C++T this[int index] { get; set; }Property Item(index As Integer) As TT this[int index] { get; set; }
- index
The zero-based index of the element to get or set.
- Value
- T T T T
The element at the specified index.
index is not a valid index in the System.Collections.Generic.IList`1.
The property is set and the System.Collections.Generic.IList`1 is read-only.
Size Size Size Size
Gets the number of HttpChallengeHeaderValue objects in the collection.
public : unsigned int Size { get; }This member is not implemented in C#This member is not implemented in VB.Net// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The number of HttpChallengeHeaderValue objects in the HttpChallengeHeaderValueCollection.
Remarks
The Size value returns the true number of items. API that use the index, such as IndexOf, use a zero-based index, so you would subtract one from Size in order to specify that you want the last item in the collection.
If you are programming using C# or Microsoft Visual Basic, the equivalent method is Count.
Methods
Append(HttpChallengeHeaderValue) Append(HttpChallengeHeaderValue) Append(HttpChallengeHeaderValue) Append(HttpChallengeHeaderValue)
Adds a new HttpChallengeHeaderValue item to the end of the collection.
public : void Append(HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- value
- HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue
The HttpChallengeHeaderValue object to append.
Remarks
After you've added an item, you can use the IndexOf method to get it by index.
To add an item to a position in the collection that's not at the collection end, use the InsertAt method.
If you are programming using C# or Microsoft Visual Basic, the equivalent method is Add.
- See Also
Clear() Clear() Clear() Clear()
Removes all HttpChallengeHeaderValue objects from the collection.
public : void Clear()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- See Also
First() First() First() First()
Retrieves an iterator to the first HttpChallengeHeaderValue item in the collection.
public : IIterator<HttpChallengeHeaderValue> First()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
An object that can be used to enumerate the HttpChallengeHeaderValue items in the collection. The iterator points to the first HttpChallengeHeaderValue item in the HttpChallengeHeaderValueCollection.
- See Also
GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)
Returns the HttpChallengeHeaderValue at the specified index in the collection.
public : HttpChallengeHeaderValue GetAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- index
- unsigned int UInt32 UInt32 UInt32
The zero-based index of a specified item in the HttpChallengeHeaderValueCollection.
The HttpChallengeHeaderValue at the specified index in the HttpChallengeHeaderValueCollection
Remarks
If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt and SetAt methods.
- See Also
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()
Returns an enumerator that iterates through the collection.
This member is not implemented in C++IEnumerator<T> GetEnumerator()Function GetEnumerator As IEnumerator(Of T)IEnumerator<T> GetEnumerator()
An enumerator that can be used to iterate through the collection.
GetMany(UInt32, HttpChallengeHeaderValue[]) GetMany(UInt32, HttpChallengeHeaderValue[]) GetMany(UInt32, HttpChallengeHeaderValue[]) GetMany(UInt32, HttpChallengeHeaderValue[])
Retrieves the HttpChallengeHeaderValue items that start at the specified index in the collection.
public : unsigned int GetMany(unsigned int startIndex, HttpChallengeHeaderValue[] items)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- startIndex
- unsigned int UInt32 UInt32 UInt32
The zero-based index of the start of the HttpChallengeHeaderValue items in the HttpChallengeHeaderValueCollection.
- items
- HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[]
An array of HttpChallengeHeaderValue items that start at startIndex in the HttpChallengeHeaderValueCollection.
The number of HttpChallengeHeaderValue items retrieved.
Remarks
The elements are copied to the array in the same order in which the enumerator iterates through the collection. It's typical to specify startIndex as 0 if all you're doing is making a simple copy of the collection items, where you've created a destination array with a length that matches the Size of the collection you're copying.
This method will throw an exception if the number of elements in the source collection is greater than the length of the destination array specified in items.
If you are programming using Visual C++ component extensions (C++/CX) or JavaScript, CopyTo has similar behavior to GetMany, but note that the parameters are in a different order. Or you can make an IVectorView copy by calling the GetView method.
- See Also
GetView() GetView() GetView() GetView()
Returns an immutable view of the HttpChallengeHeaderValueCollection.
public : IVectorView<HttpChallengeHeaderValue> GetView()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
The view of the HttpChallengeHeaderValueCollection.
Remarks
When programming with .NET, this method is hidden.
IndexOf(T) IndexOf(T) IndexOf(T) IndexOf(T)
Determines the index of a specific item in the System.Collections.Generic.IList`1.
This member is not implemented in C++int IndexOf(T item)Function IndexOf(item As T) As Integerint IndexOf(T item)
- item
- T T T T
The object to locate in the System.Collections.Generic.IList`1.
The index of item if found in the list; otherwise, -1.
IndexOf(HttpChallengeHeaderValue, UInt32) IndexOf(HttpChallengeHeaderValue, UInt32) IndexOf(HttpChallengeHeaderValue, UInt32) IndexOf(HttpChallengeHeaderValue, UInt32)
Retrieves the index of an HttpChallengeHeaderValue in the collection.
public : PlatForm::Boolean IndexOf(HttpChallengeHeaderValue value, unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- value
- HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue
The HttpChallengeHeaderValue to find in the HttpChallengeHeaderValueCollection.
- index
- unsigned int UInt32 UInt32 UInt32
The index of the HttpChallengeHeaderValue in the HttpChallengeHeaderValueCollection.
If the item is found, this is the zero-based index of the item; otherwise, this parameter is 0.
Indicates whether the item is found.
true if the HttpChallengeHeaderValue item is found; otherwise, false.
Remarks
If you are programming using C# or Microsoft Visual Basic, the equivalent method is IndexOf.
- See Also
Insert(Int32, T) Insert(Int32, T) Insert(Int32, T) Insert(Int32, T)
Inserts an item to the System.Collections.Generic.IList`1 at the specified index.
This member is not implemented in C++void Insert(int index, T item)Sub Insert(index As Integer, item As T)void Insert(int index, T item)
- index
The zero-based index at which item should be inserted.
- item
- T T T T
The object to insert into the System.Collections.Generic.IList`1.
index is not a valid index in the System.Collections.Generic.IList`1.
The System.Collections.Generic.IList`1 is read-only.
InsertAt(UInt32, HttpChallengeHeaderValue) InsertAt(UInt32, HttpChallengeHeaderValue) InsertAt(UInt32, HttpChallengeHeaderValue) InsertAt(UInt32, HttpChallengeHeaderValue)
Inserts an HttpChallengeHeaderValue into the collection at the specified index.
public : void InsertAt(unsigned int index, HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- index
- unsigned int UInt32 UInt32 UInt32
The zero-based index at which value should be inserted.
- value
- HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue
The object to insert into the collection.
Remarks
To add an item to the end position in the collection, you can use the Append method. Calling InsertAt with an index value that is the same as the Size value is equivalent to calling Append.
If you are programming using C# or Microsoft Visual Basic, the equivalent method is Insert.
ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String)
Parses and adds an entry to the HttpChallengeHeaderValueCollection.
public : void ParseAdd(PlatForm::String input)public void ParseAdd(String input)Public Function ParseAdd(input As String) As void// You can use this method in JavaScript.
- input
- PlatForm::String String String String
The entry to add.
Remarks
Below are exceptions that this function throws.
E_INVALIDARG
The input parameter is null (Nothing in Visual Basic).
The input parameter is not a valid value for the Proxy-Authenticate or WWW-Authenticate HTTP header.
- See Also
RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)
Removes the System.Collections.Generic.IList`1 item at the specified index.
This member is not implemented in C++void RemoveAt(int index)Sub RemoveAt(index As Integer)void RemoveAt(int index)
- index
The zero-based index of the item to remove.
index is not a valid index in the System.Collections.Generic.IList`1.
The System.Collections.Generic.IList`1 is read-only.
RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32)
Removes the entry at the specified index from the HttpChallengeHeaderValueCollection.
public : void RemoveAt(unsigned int index)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- index
- unsigned int UInt32 UInt32 UInt32
The index of the entry to remove.
Remarks
If successful, calling this method reduces the collection size by one. Items with index values greater than the called index have their index values reduced by one.
If you are programming using C# or Microsoft Visual Basic, the equivalent method is RemoveAt. The behavior of each language's RemoveAt is basically the same.
- See Also
RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()
Removes the last HttpChallengeHeaderValue item from the collection.
public : void RemoveAtEnd()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
Remarks
When programming with .NET, this method is hidden and developers should use Remove.
ReplaceAll(HttpChallengeHeaderValue[]) ReplaceAll(HttpChallengeHeaderValue[]) ReplaceAll(HttpChallengeHeaderValue[]) ReplaceAll(HttpChallengeHeaderValue[])
Replaces all the HttpChallengeHeaderValue items in the collection with the specified HttpChallengeHeaderValue items.
public : void ReplaceAll(HttpChallengeHeaderValue[] items)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- items
- HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[] HttpChallengeHeaderValue[]
The collection of HttpChallengeHeaderValue items to add to the collection.
Remarks
When programming with .NET, this method is hidden.
SetAt(UInt32, HttpChallengeHeaderValue) SetAt(UInt32, HttpChallengeHeaderValue) SetAt(UInt32, HttpChallengeHeaderValue) SetAt(UInt32, HttpChallengeHeaderValue)
Sets the HttpChallengeHeaderValue at the specified index in the collection.
public : void SetAt(unsigned int index, HttpChallengeHeaderValue value)This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
- index
- unsigned int UInt32 UInt32 UInt32
The zero-based index at which to set the HttpChallengeHeaderValue.
- value
- HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue HttpChallengeHeaderValue
The item to set.
Remarks
If you are programming using C# or Microsoft Visual Basic, the equivalent method is Item for the GetAt and SetAt methods.
ToString() ToString() ToString() ToString()
Returns a string that represents the current HttpChallengeHeaderValueCollection object.
public : PlatForm::String ToString()public string ToString()Public Function ToString() As string// You can use this method in JavaScript.
A string that represents the current object.
TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String)
Tries to parse and add the specified item to the HttpChallengeHeaderValueCollection.
public : PlatForm::Boolean TryParseAdd(PlatForm::String input)public bool TryParseAdd(String input)Public Function TryParseAdd(input As String) As bool// You can use this method in JavaScript.
- input
- PlatForm::String String String String
The item to parse and add.
true if the item successfully parsed and was added; otherwise false.