Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkFtp2W.h>
void ChilkatSample(void)
{
BOOL success;
HCkFtp2W ftp;
success = FALSE;
ftp = CkFtp2W_Create();
CkFtp2W_putHostname(ftp,L"ftp.example.com");
CkFtp2W_putUsername(ftp,L"myFtpLogin");
// The HTTP proxy through which the FTP control connection is made. Common ports are 8080 and
// 3128.
CkFtp2W_putHttpProxyHostname(ftp,L"proxy.example.com");
CkFtp2W_putHttpProxyPort(ftp,8080);
// Proxy authentication, if required. HttpProxyAuthMethod is "Basic" or "NTLM"; HttpProxyDomain
// is the Windows domain used for NTLM.
CkFtp2W_putHttpProxyUsername(ftp,L"myProxyLogin");
CkFtp2W_putHttpProxyPassword(ftp,L"myProxyPassword");
CkFtp2W_putHttpProxyAuthMethod(ftp,L"NTLM");
CkFtp2W_putHttpProxyDomain(ftp,L"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.
CkFtp2W_putPassword(ftp,L"myPassword");
success = CkFtp2W_Connect(ftp);
if (success == FALSE) {
wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
CkFtp2W_Dispose(ftp);
return;
}
wprintf(L"Connected through the HTTP proxy.\n");
success = CkFtp2W_Disconnect(ftp);
if (success == FALSE) {
wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
CkFtp2W_Dispose(ftp);
return;
}
CkFtp2W_Dispose(ftp);
}