FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

Non-Chilkat Links
Text and String Handling

HTTP Redirect Handling

Examine HTTP redirects.

Download Chilkat HTTP ActiveX

LOCAL loHttp
LOCAL lnSuccess
LOCAL lcUrl
LOCAL lcHtml
LOCAL lnStatus

loHttp = CreateObject('Chilkat.Http')

*  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loHttp.LastErrorText)
    QUIT
ENDIF

lcUrl = "http://www.planyourweddingonline.co.za/"

*  The FollowRedirects property controls whether redirects
*  are automatically followed.  The default behavior is to
*  automatically follow redirects.

*  Explicitly set FollowRedirects so that redirects are automatically taken:
loHttp.FollowRedirects = 1

*  Send the HTTP GET and return the content in a string.
lcHtml = loHttp.QuickGetStr(lcUrl)
IF (lcHtml = NULL ) THEN
    =MESSAGEBOX(loHttp.LastErrorText)
ENDIF

*  On success, LastErrorText will provide information about
*  what happened during the call.
? "--------------- LastErrorText ------------------"
? loHttp.LastErrorText
? "------------------------------------------------"

*  In this case, we see something like this:
*  ChilkatLog:
*    QuickGetHtml:
*      DllDate: Jul 27 2007
*      url: http://www.planyourweddingonline.co.za/
*      httpServer: www.planyourweddingonline.co.za
*      port: 80
*      StatusCode: 302
*      StatusText: Found
*      Reading chunked response
*      redirectUrl: main/main/home/index.php
*      url: http://www.planyourweddingonline.co.za/main/main/home/index.php
*      StatusCode: 302
*      StatusText: Found
*      Reading chunked response
*      redirectUrl: /main/main/home/index.php?SMC=1
*      url: http://www.planyourweddingonline.co.za/main/main/home/index.php?SMC=1
*      StatusCode: 200
*      StatusText: OK
*      CompressedSize: 7434
*      UncompressedSize: 40999

*  Was the GET redirected?
IF (loHttp.WasRedirected = 1) THEN
    ? "Chilkat HTTP followed the redirect."

    *  Display the final redirect URL:
    ? "Final URL:"
    ? loHttp.FinalRedirectUrl

    *  Note the HTML returned is from the final redirect URL.

ELSE
    ? "Not redirected."
ENDIF

lnStatus = loHttp.LastStatus
IF (lnStatus = 200) THEN
    ? "status = 200, OK!"
ELSE
    ? "HTTP Response status = " + STR(lnStatus)

    *  Display the complete response header.
    ? loHttp.LastResponseHeader
ENDIF

*  Now try it without following redirects:
? "-------- Now trying without following redirects...."
loHttp.FollowRedirects = 0

*  Send the HTTP GET and return the content in a string.
lcHtml = loHttp.QuickGetStr(lcUrl)
IF (lcHtml = NULL ) THEN
    *  the HTML string can NULL if a 302 redirect response is received.
    ? "HTML string returned NULL..."
ENDIF

*  On success, LastErrorText will provide information about
*  what happened during the call.
? "--------------- LastErrorText ------------------"
? loHttp.LastErrorText
? "------------------------------------------------"

*  In this case, we see something like this:
*  ChilkatLog:
*    QuickGetHtml:
*      DllDate: Jul 27 2007
*      url: http://www.planyourweddingonline.co.za/
*      StatusCode: 302
*      StatusText: Found
*      Reading chunked response
*      redirectUrl: main/main/home/index.php

*  Was this a redirect?  Even if FollowRedirects is false,
*  WasRedirected will be true (non-zero) if the response
*  indicated a redirect.
IF (loHttp.WasRedirected = 1) THEN
    ? "This was a redirect response"

    *  When redirects are not followed, FinalRedirectUrl
    *  contains the redirect URL that would've been taken...
    *  Display the redirect URL, which was not taken...
    ? "Redirect URL:"
    ? loHttp.FinalRedirectUrl

ELSE
    ? "Not redirected."
ENDIF

lnStatus = loHttp.LastStatus
IF (lnStatus = 200) THEN
    ? "status = 200, OK!"
ELSE
    ? "HTTP Response status = " + STR(lnStatus)

    *  Display the complete response header.
    ? loHttp.LastResponseHeader
ENDIF

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser