Tcl
Tcl
Connect to FTP Through an HTTP Proxy
See more FTP Examples
Demonstrates connecting through an HTTP proxy using HttpProxyHostname, HttpProxyPort, HttpProxyUsername, HttpProxyPassword, HttpProxyAuthMethod, and HttpProxyDomain.
Background: Many corporate networks force outbound traffic through an HTTP proxy, which reaches the FTP control connection via the
CONNECT method — so the proxy must permit CONNECT to the FTP port. HttpProxyAuthMethod is Basic or NTLM, with HttpProxyDomain supplying the Windows domain for NTLM. This is distinct from a traditional FTP proxy, which speaks FTP itself.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
set ftp [new_CkFtp2]
CkFtp2_put_Hostname $ftp "ftp.example.com"
CkFtp2_put_Username $ftp "myFtpLogin"
# The HTTP proxy through which the FTP control connection is made. Common ports are 8080 and
# 3128.
CkFtp2_put_HttpProxyHostname $ftp "proxy.example.com"
CkFtp2_put_HttpProxyPort $ftp 8080
# Proxy authentication, if required. HttpProxyAuthMethod is "Basic" or "NTLM"; HttpProxyDomain
# is the Windows domain used for NTLM.
CkFtp2_put_HttpProxyUsername $ftp "myProxyLogin"
CkFtp2_put_HttpProxyPassword $ftp "myProxyPassword"
CkFtp2_put_HttpProxyAuthMethod $ftp "NTLM"
CkFtp2_put_HttpProxyDomain $ftp "CORP"
# Normally you would not hard-code the password in source. You should instead obtain it
# from an interactive prompt, environment variable, or a secrets vault.
CkFtp2_put_Password $ftp "myPassword"
set success [CkFtp2_Connect $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
puts "Connected through the HTTP proxy."
set success [CkFtp2_Disconnect $ftp]
if {$success == 0} then {
puts [CkFtp2_lastErrorText $ftp]
delete_CkFtp2 $ftp
exit
}
delete_CkFtp2 $ftp