Sample code for 30+ languages & platforms
Visual FoxPro

Get the Last-Modified Date Before HTTP Download

See more HTTP Examples

Demonstrates how to send a HEAD request to get the last-modified date of a file on a web server (without downloading the file).

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loResp
LOCAL lcLastModStr
LOCAL loCkdt
LOCAL loDt

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat.Http')

loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpNoBody("HEAD","https://www.chilkatsoft.com/hamlet.xml",loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loResp
    CANCEL
ENDIF

* Examine the response header.
? loResp.Header

* 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.
lcLastModStr = loResp.GetHeaderField("Last-Modified")
* If the header exists...
IF (loResp.LastMethodSuccess = 1) THEN
    * Parse the RFC822 format date/time string
    loCkdt = CreateObject('Chilkat.CkDateTime')
    loCkdt.SetFromRfc822(lcLastModStr)

    * If we want to access individual date/time parts (in the local timezone)
    loDt = CreateObject('Chilkat.DtObj')
    loCkdt.ToDtObj(1,loDt)

    ? "day/month/year = " + STR(loDt.Day) + "/" + STR(loDt.Month) + "/" + STR(loDt.Year)
ENDIF

RELEASE loHttp
RELEASE loResp
RELEASE loCkdt
RELEASE loDt