Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Check File Size using HEAD RequestDemonstrates how to quickly check the size of an HTTP download by using the HEAD request. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int DECLARE @sTmp0 nvarchar(4000) DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Any string unlocks the component for the 1st 30-days. EXEC sp_OAMethod @http, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Send a HEAD request to get the response header: DECLARE @response int EXEC sp_OAMethod @http, 'GetHead', @response OUT, 'http://www.chilkatsoft.com/download/ChilkatDotNet2.msi' IF @response Is NULL BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END ELSE BEGIN -- The ContentLength property of the HTTP response is -- the size of the remote file: EXEC sp_OAGetProperty @response, 'ContentLength', @iTmp0 OUT PRINT 'Size of download = ' + @iTmp0 END END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.