Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... 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).
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Variant vResp Handle hoResp String sLastModStr Handle hoCkdt Boolean iSuccess Variant vDt Handle hoDt String sTemp1 Integer iTemp1 Integer iTemp2 Integer iTemp3 Boolean bTemp1 // 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 ComGetHead Of hoHttp "https://www.chilkatsoft.com/hamlet.xml" To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = 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 ComGetDtObj Of hoCkdt True To vDt If (IsComObject(vDt)) Begin Get Create (RefClass(cComChilkatDtObj)) To hoDt Set pvComObject Of hoDt To vDt End 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 Send Destroy of hoDt End Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.