WebHeaderCollection.GetValues gets an array of header values stored in a header. : WebHeaderCollection « Network Remote « VB.Net






WebHeaderCollection.GetValues gets an array of header values stored in a header.

 
Imports System.IO
Imports System.Net
Imports System.Text

public class MainClass
   Shared Sub Main()
            Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
          myHttpWebRequest.Timeout = 1000
            Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
            Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebResponse.Headers
            Dim i As Integer
            For i = 0 To myWebHeaderCollection.Count - 1
                Dim header As [String] = myWebHeaderCollection.GetKey(i)
                Dim values As [String]() = myWebHeaderCollection.GetValues(header)
                If values.Length > 0 Then
                    Console.WriteLine(header)
                    Dim j As Integer
                    For j = 0 To values.Length - 1
                        Console.WriteLine(ControlChars.Tab + "{0}", values(j))
                    Next j
                End If
            Next i
    End Sub 
End Class

   
  








Related examples in the same category

1.WebHeaderCollection.Add inserts the specified header into the collection.
2.WebHeaderCollection.IsRestricted tells whether the specified HTTP header can be set for the request.
3.WebHeaderCollection.Remove removes the specified header from the collection.
4.WebHeaderCollection.Set sets the specified header to the specified value.