Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.js

Visual Basic 6.0 Examples

Async
Certificates
ECC
Email Object
Encryption
FTP
HTML-to-XML/Text
Gzip
HTTP
IMAP
JSON
MHT / HTML Email
PEM
PFX/P12
Java KeyStore (JKS)
POP3
RSA Encryption
MIME
REST
SCP
SMTP
Socket/SSL/TLS
SSH Key
SSH
SFTP
Stream
Tar Archive
XML
XMP
Zip

More Examples...
Google APIs
Google Cloud Storage
Azure Cloud Storage
Amazon S3 (new)
Google Drive
ASN.1
PRNG
Amazon S3
Bounced Email
CSV
Diffie-Hellman
DKIM / DomainKey
DSA
NTLM
QuickBooks

 

 

 

 

 

 

 

(Visual Basic 6.0) Manually Follow HTTP Redirects

Demonstrates how to manually follow redirects for an HTTP GET.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim http As New ChilkatHttp

Dim success As Long
success = http.UnlockComponent("Anything for 30-day trial.")
If (success <> 1) Then
    Text1.Text = Text1.Text & http.LastErrorText & vbCrLf
    Exit Sub
End If

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

'  Explicitly set FollowRedirects so that redirects are NOT automatically taken:
http.FollowRedirects = 0

Dim resp As ChilkatHttpResponse

Set resp = http.QuickGetObj("http://yandex.ru/")
If (resp Is Nothing ) Then
    Text1.Text = Text1.Text & http.LastErrorText & vbCrLf
    Exit Sub
End If

Dim status As Long
status = resp.StatusCode
Text1.Text = Text1.Text & "HTTP Response Status: " & status & vbCrLf

'  The FinalRedirectUrl property will contain the redirect URL
'  If FollowRedirects was equal to 1, then all of the
'  intermediate redirects (if any) would be followed until
'  there were no more redirects.  However, because
'  FollowRedirects is not 1, FinalRedirectUrl contains
'  the next redirect URL.

Dim loopCount As Long
loopCount = 0

Do While (status = 302)

    '  IMPORTANT: This example requires Chilkat v9.5.0.49 or greater because
    '  the FinalRedirectUrl in prior versions is only set when redirects
    '  are automatically followed.   Starting in v9.5.0.49, the FinalRedirectUrl is
    '  set to the next redirect URL when a 301/302 response is received, regardless
    '  of the value of the FollowRedirects property.
    Text1.Text = Text1.Text & "Redirect URL: " & http.FinalRedirectUrl & vbCrLf

    Dim nextUrl As String
    nextUrl = http.FinalRedirectUrl
    Set resp = http.QuickGetObj(nextUrl)
    If (resp Is Nothing ) Then
        Text1.Text = Text1.Text & http.LastErrorText & vbCrLf
        Exit Sub
    End If

    status = resp.StatusCode
    Text1.Text = Text1.Text & "HTTP Response Status: " & status & vbCrLf

    '  For safety, prevent infinite loops by
    '  keeping a loopCount and only allows following a max
    '  of 10 redirects:
    loopCount = loopCount + 1
    If (loopCount > 10) Then

        Text1.Text = Text1.Text & "Too many redirects." & vbCrLf
        Exit Sub
    End If

Loop

 

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