Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Classic ASP) HTTP in a Background Thread (Asynchronous HTTP)

Notice: The functionality described here is deprecated and replaced by a newer model for asynchronous method calls. The newer model was introduced in Chilkat v9.5.0.52, and is identified by methods having names ending in “Async” which return a task object. This example shows the technique one would follow to run any Chilkat HTTP method in a background task. (Only HTTP methods that communicate with an HTTP server are background-enabled. Methods that perform no HTTP communications return immediately and never need to be backgrounded.)

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set http = Server.CreateObject("Chilkat_9_5_0.Http")

'  Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"

End If

'  Notice: The functionality described here is deprecated and replaced by a newer model
'  for asynchronous method calls. The newer model was introduced in Chilkat v9.5.0.52,
'  and is identified by methods having names ending in “Async” which return a task object.

'  To run an HTTP method asynchronously in a background thread, set
'  the UseBgThread property equal to 1
http.UseBgThread = 1

'  For those programming languages that support event callbacks:
'  events are not fired when a task is running in the background thread.
'  Instead, Chilkat has added the "event log" mechanism.  While the
'  background task is running, events that normally would've been fired
'  are accumulated in the event log.  Your application may periodically check
'  the event log to keep track of the progress of the background task.
'  To enable event logging, set the KeepEventLog property = 1
http.KeepEventLog = 1

'  Start an asynchronous HTTP download in a background thread.
'  The method will return cktrue if the task was successfully started.
'  Note: When the UseBgThread property = 1, all methods involving
'  HTTP communications will be asynchronous.  These methods include:
'  SynchronousRequest, QuickGetStr, QuickGet, PostUrlEncoded, XmlRpc,
'  XmlRpcPut, QuickPutStr, QuickGetObj, QuickDeleteStr, PutText,
'  PutBinary, PostBinary, PostMime, GetHead, DownloadAppend, etc.
success = http.Download("http://www.chilkatsoft.com/download/ChilkatJava.zip","ChilkatJava.zip")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"

Else
    Response.Write "<pre>" & Server.HTMLEncode( "Initiated asynchronous HTTP download...") & "</pre>"
End If

'  Write a loop to wait for the background task to complete.
'  Your application would typically do something different than this --
'  after all... there's no point in doing the task asynchronously if your application
'  is simply going to wait for it to complete -- that's the same as doing it synchronously,
'  and that could've been achieved by a single call to the http.Download method
'  with the UseBgThread = 0.
'  However... we do this here for the purpose of demonstration...
Do While (http.BgTaskRunning = 1)

    '  Show the events in the event log that have accumulated so far...
    n = http.EventLogCount
    If (n > 0) Then

        For i = 0 To n - 1
            Response.Write "<pre>" & Server.HTMLEncode( http.EventLogName(i) & ": " & http.EventLogValue(i)) & "</pre>"
        Next
        http.ClearBgEventLog 
    End If

    '  In some programming languages, you might wish to handle user-interface events
    '  For example, in C#  you might call Application.DoEvents()

    '  Sleep .1 seconds -- to keep the CPU from being 100% busy...
    http.SleepMs 100
Loop

'  Once the background task has completed, check it for success/failure:
If (http.BgTaskSuccess = 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Background task completed successfully.") & "</pre>"
Else
    Response.Write "<pre>" & Server.HTMLEncode( "Failed.") & "</pre>"
    '  The error information is in the BgLastErrorText for background tasks.
    Response.Write "<pre>" & Server.HTMLEncode( http.BgLastErrorText) & "</pre>"
End If


%>
</body>
</html>

 

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