Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Tcl Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
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)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(Tcl) Debugging HTTP

The 1st step in debugging a failed HTTP request (or determining the reason for an unexpected response) is to get more information about what actually happened. The Chilkat HTTP component/class have properties that provide this information. The most useful is the SessionLogFilename property. It may be set to a filepath that is to be created or appended by the HTTP component. The exact HTTP requests and responses are logged to this file. The session log file can be examined to verify that the HTTP request(s) sent to the web server contain the expected data and are structurally formatted as expected.

The standard LastErrorText / LastErrorXml / LastErrorHtml properties can also provide information about what transpired. These properties are standard to all Chilkat components/classes, and contain information about what transpired (for a given object instance) for the very last method called. Regardless of the success or failure status returned by the method, the LastErrorText will always contain information. The VerboseLogging property may be set to 1 to get more detailed information in LastErrorText. (It is best to first examine the LastErrorText without VerboseLogging, and then only use VerboseLogging if necessary.)

Other properties exist to provide less detailed, but more succinct and easily accessible information, such as LastHeader, LastStatus, WasRedirected, LastContentType, etc.

Important: The SessionLogFilename, LastErrorText, and other debugging related properties apply to ALL Chilkat HTTP methods that communicate with an HTTP server.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

set http [new_CkHttp]

#  Any string unlocks the component for the 1st 30-days.
set success [CkHttp_UnlockComponent $http "Anything for 30-day trial"]
if {[expr $success != 1]} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    exit
}

#  This example demonstrates session logging via the
#  SessionLogFilename property.  It also examines the
#  contents of the LastErrorText and a few other properties
#  to see what transpired in a seemingly simple HTTP GET request.

CkHttp_put_SessionLogFilename $http "/temp/httpSessionLog.txt"

#  The "http://www.paypal.com" URL was chosen on
#  purpose to demonstrate the potential complexity
#  of a seemingly simple HTTP GET request and response.
# 
#  In this case, the initial response is a 301 redirect to
#  "https://www.paypal.com/" because all communication
#  with PayPal must be over SSL/TLS.  The Chilkat HTTP
#  FollowRedirects property defaults to 1, causing the
#  redirect to be followed automatically.
#  The request is resent using SSL/TLS and the response
#  received is a complex one:  it is both Gzipped (compressed)
#  and "chunked".  Internally, Chilkat automatically handles
#  the decompression and the re-composing of the chunked
#  response to return the simple HTML page that is the result.

set html [CkHttp_quickGetStr $http "http://www.paypal.com/"]

#  Looking at the httpSessionLog, we can see the initial
#  HTTP request, the 301 response, the subsequent
#  HTTP GET request to follow the redirect, and the final
#  gzipped/chunked response:

#  ---- Sending ----
#  GET / HTTP/1.1
#  Accept: */*
#  Accept-Encoding: gzip
#  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
#  Accept-Language: en-us,en;q=0.5
#  Host: www.paypal.com
#  Connection: Keep-Alive
# 
# 
#  ---- Received ----
#  HTTP/1.1 301 Moved Permanently
#  Date: Sat, 25 Jun 2011 14:50:36 GMT
#  Server: Apache
#  Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG..; domain=.paypal.com; path=/; HttpOnly
#  Set-Cookie: cookie_check=yes; expires=Tue, 22-Jun-2021 14:50:37 GMT; domain=.paypal.com; path=/; HttpOnly
#  Location: https://www.paypal.com/
#  Vary: Accept-Encoding
#  Content-Encoding: gzip
#  Keep-Alive: timeout=5, max=100
#  Connection: Keep-Alive
#  Transfer-Encoding: chunked
#  Content-Type: text/html
# 
#  10
#  (10 bytes of binary (non-printable) data here...)
# 
#  ---- Sending ----
#  GET / HTTP/1.1
#  Accept: */*
#  Accept-Encoding: gzip
#  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
#  Accept-Language: en-us,en;q=0.5
#  Host: www.paypal.com
#  Connection: Keep-Alive
# 
# 
#  ---- Received ----
#  HTTP/1.1 200 OK
#  Date: Sat, 25 Jun 2011 14:50:37 GMT
#  Server: Apache
#  Cache-Control: private
#  Pragma: no-cache
#  Expires: Thu, 05 Jan 1995 22:00:00 GMT
#  Set-Cookie: cwrClyrK4DoCV1fydGbAxiNL6iG=jE8s ...; domain=.paypal.com; path=/; Secure; HttpOnly
#  Set-Cookie: KHcl0EuY7AKSMgfvHl7J5E7hPtK=YSG ...; expires=Fri, 20-Jun-2031 14:50:38 GMT;
#   domain=.paypal.com; path=/; Secure; HttpOnly
#  Set-Cookie: cookie_check=yes; expires=Tue, 22-Jun-2021 14:50:38 GMT; domain=.paypal.com; path=/;
#   Secure; HttpOnly
#  Set-Cookie: navcmd=_home-general; domain=.paypal.com; path=/; Secure; HttpOnly
#  Set-Cookie: consumer_display=USER_HOMEPAGE...;
#   expires=Tue, 22-Jun-2021 14:50:38 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
#  Set-Cookie: navlns=0.0; expires=Fri, 20-Jun-2031 14:50:38 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
#  Set-Cookie: Apache=10.73.8.36.1309013437867506; path=/; expires=Mon, 17-Jun-41 14:50:37 GMT
#  Vary: Accept-Encoding
#  Content-Encoding: gzip
#  Strict-Transport-Security: max-age=500
#  Keep-Alive: timeout=5, max=100
#  Connection: Keep-Alive
#  Transfer-Encoding: chunked
#  Content-Type: text/html; charset=UTF-8
# 
#  1895
#  (The remainder of the HTTP response is binary data.)

delete_CkHttp $http

 

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