Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Value Property
Collapse the table of content
Expand the table of content

Value Property

Visual Studio .NET 2003

Gets or sets the value part of an HTTP header name-value pair.

strValue = Header.Value [ = strName ]

Return value

strValue As String. The value part of the HTTP header.

Remarks

A Header object can represent a field from either a response header or a request header.

Examples

 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function to get a resource's size by sending a HEAD 
' request to the server and checking the value of the 
' Content-Length header field.
'
Function GetResourceSize(strServer, strPath)   
   Dim oConnection, oRequest, oResponse, oContentLengthHeader
   Dim strContentLength

   Set oConnection = Test.CreateConnection(strServer)
   ' check for connection errors
   If (oConnection Is Nothing) Then
      Test.Trace("Error: Unable to create connection.")
   Else
      Set oRequest = Test.CreateRequest
      oRequest.Path = strPath
      oRequest.Verb = "HEAD"
      Set oResponse = oConnection.Send(oRequest)
      If (oRequest Is Nothing) Then
         Call Test.Trace("Error: invalid request or host not found ")
      Else
         If (oResponse.ResultCode = "200") Then
            Set oContentLengthHeader = oResponse.Headers.Item("Content-Length")
            strContentLength = "Content-Length=" & oContentLengthHeader.Value
         Else
            strContentLength = "Error, status code: " & oResponse.ResultCode
         End If
      End If
      Call oConnection.Close()
   End If

   GetResourceSize = strContentLength
End Function
 

See Also

Header object | Headers.Item property | Header.Name

Show:
© 2015 Microsoft