計數

傳回 HTTPHeaders 物件中的標頭項目數。

語法

HTTPHeadersObject.Count

其中:

  • Count 是長整數(讀)
範例

該指令碼將列印標頭:

Function Main

Dim HTTPObj as Object

Dim headers as Object

ip = "www.gfi.com"

port = 80

cr = Chr(13) + Chr(10)

Set HTTPobj = HTTP.Connect (ip,port)

'設定要求類型

HTTPobj.GetURL("/")

HTTPobj.verb = "HEAD"

'傳送 HEAD 要求

HTTPResponse = HTTPobj.SendRequest ()

'設定新的標頭物件

Set headers = HTTPobj.ResponseHeaders

'headers.count 包含標頭的數量(長)

echo "標題計數: " & CStr(headers.Count) & cr

upbound = headers.Count - 1

'對於每個標頭,回應標頭名稱和標頭值

For hn=0 To upbound

echo headers.HeaderName(hn) & vbTab & "-->" & vbtab & headers.HeaderValue(hn) & cr

下一步

End Function