![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Get the Last-Modified Date Before HTTP DownloadDemonstrates how to send a HEAD request to get the last-modified date of a file on a web server (without downloading the file). Note: This example requires Chilkat v11.0.0 or greater.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoHttp Variant vResp Handle hoResp String sLastModStr Handle hoCkdt Variant vDt Handle hoDt String sTemp1 Integer iTemp1 Integer iTemp2 Integer iTemp3 Boolean bTemp1 Move False To iSuccess // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Get Create (RefClass(cComChilkatHttpResponse)) To hoResp If (Not(IsComObjectCreated(hoResp))) Begin Send CreateComObject of hoResp End Get pvComObject of hoResp to vResp Get ComHttpNoBody Of hoHttp "HEAD" "https://www.chilkatsoft.com/hamlet.xml" vResp To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // Examine the response header. Get ComHeader Of hoResp To sTemp1 Showln sTemp1 // Here is a sample response header: // Content-Length: 279658 // Content-Type: text/xml // Last-Modified: Thu, 12 May 2016 15:14:08 GMT // Accept-Ranges: bytes // ETag: "c1cd8bee60acd11:0" // Server: Microsoft-IIS/8.5 // X-Powered-By: ASP.NET // X-Powered-By-Plesk: PleskWin // Date: Thu, 25 Jul 2019 16:40:54 GMT // Get the Last-Modified header. Get ComGetHeaderField Of hoResp "Last-Modified" To sLastModStr // If the header exists... Get ComLastMethodSuccess Of hoResp To bTemp1 If (bTemp1 = True) Begin // Parse the RFC822 format date/time string Get Create (RefClass(cComCkDateTime)) To hoCkdt If (Not(IsComObjectCreated(hoCkdt))) Begin Send CreateComObject of hoCkdt End Get ComSetFromRfc822 Of hoCkdt sLastModStr To iSuccess // If we want to access individual date/time parts (in the local timezone) Get Create (RefClass(cComChilkatDtObj)) To hoDt If (Not(IsComObjectCreated(hoDt))) Begin Send CreateComObject of hoDt End Get pvComObject of hoDt to vDt Send ComToDtObj To hoCkdt True vDt Get ComDay Of hoDt To iTemp1 Get ComMonth Of hoDt To iTemp2 Get ComYear Of hoDt To iTemp3 Showln "day/month/year = " iTemp1 "/" iTemp2 "/" iTemp3 End End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.