Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoFtp
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatFtp2)) To hoFtp
    If (Not(IsComObjectCreated(hoFtp))) Begin
        Send CreateComObject of hoFtp
    End

    Set ComHostname Of hoFtp To "ftp.example.com"
    Set ComUsername Of hoFtp To "myFtpLogin"

    //  The HTTP proxy through which the FTP control connection is made.  Common ports are 8080 and
    //  3128.
    Set ComHttpProxyHostname Of hoFtp To "proxy.example.com"
    Set ComHttpProxyPort Of hoFtp To 8080

    //  Proxy authentication, if required.  HttpProxyAuthMethod is "Basic" or "NTLM"; HttpProxyDomain
    //  is the Windows domain used for NTLM.
    Set ComHttpProxyUsername Of hoFtp To "myProxyLogin"
    Set ComHttpProxyPassword Of hoFtp To "myProxyPassword"
    Set ComHttpProxyAuthMethod Of hoFtp To "NTLM"
    Set ComHttpProxyDomain Of hoFtp To "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.
    Set ComPassword Of hoFtp To "myPassword"

    Get ComConnect Of hoFtp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Connected through the HTTP proxy."

    Get ComDisconnect Of hoFtp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoFtp To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure