VBScript Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VBScript Examples

Bounced Mail
Bz2
Character Encoding
Digital Certificates
CSV
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
Byte Array
RSS
Atom
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

HTTP Redirect Handling

Download Chilkat HTTP ActiveX

Examine HTTP redirects.

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

set http = CreateObject("Chilkat.Http")

'  Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    MsgBox http.LastErrorText
    WScript.Quit
End If

url = "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:
http.FollowRedirects = 1

'  Send the HTTP GET and return the content in a string.
html = http.QuickGetStr(url)
If (html = vbNullString ) Then
    MsgBox http.LastErrorText
End If

'  On success, LastErrorText will provide information about
'  what happened during the call.
outFile.WriteLine("--------------- LastErrorText ------------------")
outFile.WriteLine(http.LastErrorText)
outFile.WriteLine("------------------------------------------------")

'  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 (http.WasRedirected = 1) Then
    outFile.WriteLine("Chilkat HTTP followed the redirect.")

    '  Display the final redirect URL:
    outFile.WriteLine("Final URL:")
    outFile.WriteLine(http.FinalRedirectUrl)

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

Else
    outFile.WriteLine("Not redirected.")
End If

status = http.LastStatus
If (status = 200) Then
    outFile.WriteLine("status = 200, OK!")
Else
    outFile.WriteLine("HTTP Response status = " _
         & status)

    '  Display the complete response header.
    outFile.WriteLine(http.LastResponseHeader)
End If

'  Now try it without following redirects:
outFile.WriteLine("-------- Now trying without following redirects....")
http.FollowRedirects = 0

'  Send the HTTP GET and return the content in a string.
html = http.QuickGetStr(url)
If (html = vbNullString ) Then
    '  the HTML string can NULL if a 302 redirect response is received.
    outFile.WriteLine("HTML string returned NULL...")
End If

'  On success, LastErrorText will provide information about
'  what happened during the call.
outFile.WriteLine("--------------- LastErrorText ------------------")
outFile.WriteLine(http.LastErrorText)
outFile.WriteLine("------------------------------------------------")

'  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 (http.WasRedirected = 1) Then
    outFile.WriteLine("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...
    outFile.WriteLine("Redirect URL:")
    outFile.WriteLine(http.FinalRedirectUrl)

Else
    outFile.WriteLine("Not redirected.")
End If

status = http.LastStatus
If (status = 200) Then
    outFile.WriteLine("status = 200, OK!")
Else
    outFile.WriteLine("HTTP Response status = " _
         & status)

    '  Display the complete response header.
    outFile.WriteLine(http.LastResponseHeader)
End If

outFile.Close

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

Mail Component · XML Parser