Check File Size using HEAD Request
Demonstrates how to quickly check the size of an HTTP download by using the HEAD request.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set http = Server.CreateObject("Chilkat_9_5_0.Http")
' Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode(http.LastErrorText) & "</pre>"
End If
' Send a HEAD request to get the response header:
' response is a Chilkat_9_5_0.HttpResponse
Set response = http.GetHead("http://www.chilkatsoft.com/download/ChilkatDotNet2.msi")
If (response Is Nothing ) Then
Response.Write "<pre>" & Server.HTMLEncode(http.LastErrorText) & "</pre>"
Else
' The ContentLength property of the HTTP response is
' the size of the remote file:
Response.Write "<pre>" & Server.HTMLEncode( "Size of download = " _
& response.ContentLength) & "</pre>"
End If
%>
</body>
</html>
|