Class HttpClient


  • public class HttpClient
    extends java.lang.Object
    Title: Unlimited FTP Description: Web based FTP client applet Copyright: Copyright (c) 2001 Company: Unlimi-Tech Software Inc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String command  
      java.lang.String servletLocation  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpClient​(java.lang.String host, int port, java.lang.String servletLocation, unlimited.core.util.common.logs.LogUtils log)  
      HttpClient​(java.lang.String Host, java.lang.String Cgihost, unlimited.core.util.common.logs.LogUtils log)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void abort()
      Send Abort command
      void allo​(long size)  
      java.io.BufferedWriter appendAscii​(java.lang.String filename)
      APPEND (with create) to a file to the FTP server in Ascii mode
      java.io.BufferedOutputStream appendBinary​(java.lang.String filename)
      APPEND (with create) to a file to the FTP server in Binary mode
      boolean ascii()
      Set transfer type to 'A'
      boolean binary()
      Set transfer type to 'I'
      void cd​(java.lang.String remoteDirectory)
      CD to a specific directory on a remote FTP server
      void cdup()  
      void closeServer()
      issue the QUIT command to the FTP server and close the connection.
      java.io.BufferedOutputStream concatenate​(java.lang.String filename, int numOfParts)
      CONCAT a bunch of files on the FTP server
      protected void configureSSLIfNeeded​(java.lang.String Cgihost)  
      boolean connected()  
      java.net.URL constructURL​(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site)  
      java.net.URL constructURL​(java.lang.String cmd, java.lang.String newDir, java.lang.String file, java.lang.String site, boolean reinitIfInvalid)  
      void delete​(java.lang.String s, boolean stripPath)  
      void deleteTempFiles()  
      void doesFTPServerSupportResume​(boolean usingFC3_8)  
      void email​(java.lang.String emailAddress, int statusCode, java.lang.String note)  
      void forceCloseServer()  
      boolean ftpResumeSupported()  
      void fxp​(java.lang.String fxpsid, java.lang.String filename, java.lang.String fxpFilename, boolean triangle)  
      java.io.BufferedReader getAscii​(java.lang.String filename)
      GET a file from the FTP server in Ascii mode
      java.lang.String getBaseURL​(java.lang.String concatenatedString)  
      java.io.BufferedInputStream getBinary​(java.lang.String filename)
      GET a file from the FTP server in Binary mode
      java.io.BufferedInputStream getBinary​(java.lang.String filename, long offset)
      GET a file from the FTP server in Binary mode and starting at the given offset
      java.io.BufferedInputStream getBinary​(java.lang.String filename, long offset, long segment)
      GET a file segment from the FTP server in Binary mode and starting at the given offset
      protected java.io.BufferedReader getBufferedReader​(java.net.URLConnection urlc)
      This method will try multiple times to open the data connection to the web server if it gets IO exceptions.
      java.lang.String getCertificateInfo()
      Go up one directory on remots system
      java.lang.String getCommand()  
      int getLastReplyCode()  
      protected int getMovePercentage​(java.lang.String remoteFile)
      returns true/false if the move is completed
      java.lang.String getRemoteHost()  
      int getRemotePort()  
      java.lang.String getResponseString()
      Returns all server response strings.
      java.lang.String getResponseStringNoReset()  
      protected void getServletVersion()  
      java.lang.String getSid()  
      int getSoConnectTimeout()  
      int getSoLinger()  
      int getSoTimeout()  
      java.net.URL getURL()  
      java.lang.String getWelcomeMessage()  
      boolean isEnableResume()  
      boolean isForceResume()  
      boolean isMac()  
      boolean isNetscapeFour()
      Deprecated.
      boolean isPrintSolution()  
      boolean isUseGZip()  
      java.io.BufferedInputStream list()  
      java.io.BufferedInputStream list​(java.lang.String args)  
      void login​(java.lang.String username, java.lang.String password)
      login user to a host with username user and password password
      void login​(java.util.function.Supplier<ClientCredentials> creds)
      login user to a host with username user and password password
      void mkdir​(java.lang.String s)
      Create a directory on the remote system
      void moveFilesToServer​(java.lang.String remoteFile)  
      java.io.BufferedInputStream nlist()
      NLIST files on a remote FTP server
      java.io.BufferedInputStream nlist​(java.lang.String args)
      NLIST files on a remote FTP server
      void noop()  
      void openServer​(java.lang.String host)
      open a FTP connection to host host.
      void openServer​(java.lang.String host, int port)
      open a FTP connection to host host on port port.
      java.io.BufferedWriter putAscii​(java.lang.String filename)
      PUT a file to the FTP server in Ascii mode
      java.io.BufferedOutputStream putBinary​(java.lang.String filename)
      PUT a file to the FTP server in Binary mode
      java.io.BufferedOutputStream putSegmentBinary​(java.lang.String filename, long segmentOffset, long segmentSize)
      PUT a file to the FTP server in Binary mode
      void pwd()
      Get the name of the present working directory on the ftp file system
      void quote​(java.lang.String s)  
      int readServerResponse()  
      void reinitSessionIfNeeded()  
      void rename​(java.lang.String oldFile, java.lang.String newFile)
      Rename a file on the remote server
      void rmdir​(java.lang.String s)  
      void saveFilesToWebServer()  
      void sendServer​(java.lang.String cmd)
      Sends command cmd to the server.
      void sendWeblink​(WeblinkDataContainer linkDO)
      Streams Our File Listing To The Server
      boolean serverIsOpen()  
      void setClientCredentials​(java.util.function.Supplier<ClientCredentials> creds)  
      void setDebug​(boolean debug)  
      void setEnableResume​(boolean enableResume)  
      void setForceResume​(boolean forceResume)  
      void setMac​(boolean mac)  
      protected void setMD5HashedLocalIP()  
      void setNetscapeFour​(boolean netscapeFour)
      Deprecated.
      void setPassive​(boolean mode)
      Set Passive mode Trasfers
      void setPrintSolution​(boolean printSolution)  
      void setSid​(java.lang.String sid)  
      void setSoConnectTimeout​(int i)  
      void setSoLinger​(int i)  
      void setSoTimeout​(int i)  
      void setupURLConnection​(java.net.URLConnection urlc)  
      void setUseGZip​(boolean useGZip)  
      void setWelcomeMessage​(java.lang.String welcomeMessage)  
      void site​(java.lang.String params)
      Site Command
      protected void startMOVE​(java.lang.String remoteFile)  
      java.lang.String toString()  
      protected void writeLog​(java.lang.String line)  
      void zip​(java.lang.String zipFilename, java.lang.String filenames, int compLevel, long limit)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • servletLocation

        public java.lang.String servletLocation
      • command

        public java.lang.String command
    • Constructor Detail

      • HttpClient

        public HttpClient​(java.lang.String Host,
                          java.lang.String Cgihost,
                          unlimited.core.util.common.logs.LogUtils log)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • HttpClient

        public HttpClient​(java.lang.String host,
                          int port,
                          java.lang.String servletLocation,
                          unlimited.core.util.common.logs.LogUtils log)
                   throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • setMD5HashedLocalIP

        protected void setMD5HashedLocalIP()
      • configureSSLIfNeeded

        protected void configureSSLIfNeeded​(java.lang.String Cgihost)
      • getServletVersion

        protected void getServletVersion()
                                  throws java.io.IOException,
                                         java.net.MalformedURLException
        Throws:
        java.io.IOException
        java.net.MalformedURLException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setupURLConnection

        public void setupURLConnection​(java.net.URLConnection urlc)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getURL

        public java.net.URL getURL()
      • setNetscapeFour

        @Deprecated
        public void setNetscapeFour​(boolean netscapeFour)
        Deprecated.
      • isNetscapeFour

        @Deprecated
        public boolean isNetscapeFour()
        Deprecated.
      • setPassive

        public void setPassive​(boolean mode)
        Set Passive mode Trasfers
      • serverIsOpen

        public boolean serverIsOpen()
      • readServerResponse

        public int readServerResponse()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • sendServer

        public void sendServer​(java.lang.String cmd)
        Sends command cmd to the server.
      • connected

        public boolean connected()
      • getCommand

        public java.lang.String getCommand()
      • getResponseString

        public java.lang.String getResponseString()
        Returns all server response strings.
      • getLastReplyCode

        public int getLastReplyCode()
      • getResponseStringNoReset

        public java.lang.String getResponseStringNoReset()
      • closeServer

        public void closeServer()
                         throws java.io.IOException
        issue the QUIT command to the FTP server and close the connection.
        Throws:
        java.io.IOException
      • fxp

        public void fxp​(java.lang.String fxpsid,
                        java.lang.String filename,
                        java.lang.String fxpFilename,
                        boolean triangle)
                 throws java.io.IOException,
                        unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • forceCloseServer

        public void forceCloseServer()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • openServer

        public void openServer​(java.lang.String host)
                        throws java.io.IOException,
                               java.net.UnknownHostException
        open a FTP connection to host host.
        Throws:
        java.io.IOException
        java.net.UnknownHostException
      • openServer

        public void openServer​(java.lang.String host,
                               int port)
                        throws java.io.IOException,
                               java.net.UnknownHostException
        open a FTP connection to host host on port port.
        Throws:
        java.io.IOException
        java.net.UnknownHostException
      • login

        public void login​(java.lang.String username,
                          java.lang.String password)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        login user to a host with username user and password password
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • login

        public void login​(java.util.function.Supplier<ClientCredentials> creds)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        login user to a host with username user and password password
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • doesFTPServerSupportResume

        public void doesFTPServerSupportResume​(boolean usingFC3_8)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • getAscii

        public java.io.BufferedReader getAscii​(java.lang.String filename)
                                        throws java.io.IOException
        GET a file from the FTP server in Ascii mode
        Throws:
        java.io.IOException
      • getBinary

        public java.io.BufferedInputStream getBinary​(java.lang.String filename)
                                              throws java.io.IOException
        GET a file from the FTP server in Binary mode
        Throws:
        java.io.IOException
      • getBinary

        public java.io.BufferedInputStream getBinary​(java.lang.String filename,
                                                     long offset)
                                              throws java.io.IOException
        GET a file from the FTP server in Binary mode and starting at the given offset
        Throws:
        java.io.IOException
      • getBinary

        public java.io.BufferedInputStream getBinary​(java.lang.String filename,
                                                     long offset,
                                                     long segment)
                                              throws java.io.IOException
        GET a file segment from the FTP server in Binary mode and starting at the given offset
        Throws:
        java.io.IOException
      • putAscii

        public java.io.BufferedWriter putAscii​(java.lang.String filename)
                                        throws java.io.IOException
        PUT a file to the FTP server in Ascii mode
        Throws:
        java.io.IOException
      • moveFilesToServer

        public void moveFilesToServer​(java.lang.String remoteFile)
                               throws java.io.IOException,
                                      unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • writeLog

        protected void writeLog​(java.lang.String line)
      • startMOVE

        protected void startMOVE​(java.lang.String remoteFile)
                          throws java.net.MalformedURLException,
                                 java.io.IOException
        Throws:
        java.net.MalformedURLException
        java.io.IOException
      • getMovePercentage

        protected int getMovePercentage​(java.lang.String remoteFile)
                                 throws java.net.MalformedURLException,
                                        java.io.IOException
        returns true/false if the move is completed
        Returns:
        Throws:
        java.net.MalformedURLException
        java.io.IOException - if a 500 Error occurred, i.e. HTTP request failed
      • delete

        public void delete​(java.lang.String s,
                           boolean stripPath)
                    throws java.io.IOException,
                           unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • deleteTempFiles

        public void deleteTempFiles()
                             throws java.io.IOException,
                                    unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • saveFilesToWebServer

        public void saveFilesToWebServer()
                                  throws java.io.IOException,
                                         unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • ftpResumeSupported

        public boolean ftpResumeSupported()
      • concatenate

        public java.io.BufferedOutputStream concatenate​(java.lang.String filename,
                                                        int numOfParts)
                                                 throws java.io.IOException
        CONCAT a bunch of files on the FTP server
        Throws:
        java.io.IOException
      • putBinary

        public java.io.BufferedOutputStream putBinary​(java.lang.String filename)
                                               throws java.io.IOException
        PUT a file to the FTP server in Binary mode
        Throws:
        java.io.IOException
      • putSegmentBinary

        public java.io.BufferedOutputStream putSegmentBinary​(java.lang.String filename,
                                                             long segmentOffset,
                                                             long segmentSize)
                                                      throws java.io.IOException
        PUT a file to the FTP server in Binary mode
        Throws:
        java.io.IOException
      • appendAscii

        public java.io.BufferedWriter appendAscii​(java.lang.String filename)
                                           throws java.io.IOException
        APPEND (with create) to a file to the FTP server in Ascii mode
        Throws:
        java.io.IOException
      • appendBinary

        public java.io.BufferedOutputStream appendBinary​(java.lang.String filename)
                                                  throws java.io.IOException
        APPEND (with create) to a file to the FTP server in Binary mode
        Throws:
        java.io.IOException
      • nlist

        public java.io.BufferedInputStream nlist()
                                          throws java.io.IOException
        NLIST files on a remote FTP server
        Throws:
        java.io.IOException
      • nlist

        public java.io.BufferedInputStream nlist​(java.lang.String args)
                                          throws java.io.IOException
        NLIST files on a remote FTP server
        Throws:
        java.io.IOException
      • list

        public java.io.BufferedInputStream list()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • list

        public java.io.BufferedInputStream list​(java.lang.String args)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • cd

        public void cd​(java.lang.String remoteDirectory)
                throws java.io.IOException,
                       unlimited.core.util.common.exception.FCException
        CD to a specific directory on a remote FTP server
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • rename

        public void rename​(java.lang.String oldFile,
                           java.lang.String newFile)
                    throws java.io.IOException,
                           unlimited.core.util.common.exception.FCException
        Rename a file on the remote server
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • site

        public void site​(java.lang.String params)
                  throws java.io.IOException,
                         unlimited.core.util.common.exception.FCException
        Site Command
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • allo

        public void allo​(long size)
                  throws java.io.IOException,
                         unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • binary

        public boolean binary()
                       throws java.io.IOException
        Set transfer type to 'I'
        Throws:
        java.io.IOException
      • ascii

        public boolean ascii()
                      throws java.io.IOException
        Set transfer type to 'A'
        Throws:
        java.io.IOException
      • abort

        public void abort()
                   throws java.io.IOException
        Send Abort command
        Throws:
        java.io.IOException
      • getCertificateInfo

        public java.lang.String getCertificateInfo()
                                            throws java.io.IOException
        Go up one directory on remots system
        Throws:
        java.io.IOException
      • pwd

        public void pwd()
                 throws java.io.IOException,
                        unlimited.core.util.common.exception.FCException
        Get the name of the present working directory on the ftp file system
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • noop

        public void noop()
                  throws java.io.IOException,
                         unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • quote

        public void quote​(java.lang.String s)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • cdup

        public void cdup()
                  throws java.io.IOException,
                         unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • zip

        public void zip​(java.lang.String zipFilename,
                        java.lang.String filenames,
                        int compLevel,
                        long limit)
                 throws java.io.IOException,
                        unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • email

        public void email​(java.lang.String emailAddress,
                          int statusCode,
                          java.lang.String note)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • mkdir

        public void mkdir​(java.lang.String s)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        Create a directory on the remote system
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • rmdir

        public void rmdir​(java.lang.String s)
                   throws java.io.IOException,
                          unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • sendWeblink

        public void sendWeblink​(WeblinkDataContainer linkDO)
                         throws java.io.IOException,
                                unlimited.core.util.common.exception.FCException
        Streams Our File Listing To The Server
        Parameters:
        files -
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • getBufferedReader

        protected java.io.BufferedReader getBufferedReader​(java.net.URLConnection urlc)
                                                    throws java.io.IOException
        This method will try multiple times to open the data connection to the web server if it gets IO exceptions.
        Parameters:
        urlc -
        Returns:
        Throws:
        java.io.IOException
      • constructURL

        public java.net.URL constructURL​(java.lang.String cmd,
                                         java.lang.String newDir,
                                         java.lang.String file,
                                         java.lang.String site)
                                  throws java.net.MalformedURLException,
                                         java.io.UnsupportedEncodingException,
                                         java.io.IOException
        Throws:
        java.net.MalformedURLException
        java.io.UnsupportedEncodingException
        java.io.IOException
      • constructURL

        public java.net.URL constructURL​(java.lang.String cmd,
                                         java.lang.String newDir,
                                         java.lang.String file,
                                         java.lang.String site,
                                         boolean reinitIfInvalid)
                                  throws java.net.MalformedURLException,
                                         java.io.UnsupportedEncodingException,
                                         java.io.IOException
        Throws:
        java.net.MalformedURLException
        java.io.UnsupportedEncodingException
        java.io.IOException
      • getBaseURL

        public java.lang.String getBaseURL​(java.lang.String concatenatedString)
                                    throws unlimited.core.util.common.exception.FCException,
                                           java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • setSoConnectTimeout

        public void setSoConnectTimeout​(int i)
      • setSoTimeout

        public void setSoTimeout​(int i)
      • setSoLinger

        public void setSoLinger​(int i)
      • getSoConnectTimeout

        public int getSoConnectTimeout()
      • getSoTimeout

        public int getSoTimeout()
      • getSoLinger

        public int getSoLinger()
      • isPrintSolution

        public boolean isPrintSolution()
      • setPrintSolution

        public void setPrintSolution​(boolean printSolution)
      • isUseGZip

        public boolean isUseGZip()
      • setUseGZip

        public void setUseGZip​(boolean useGZip)
      • setEnableResume

        public void setEnableResume​(boolean enableResume)
      • isEnableResume

        public boolean isEnableResume()
      • setDebug

        public void setDebug​(boolean debug)
      • setMac

        public void setMac​(boolean mac)
      • isMac

        public boolean isMac()
      • getSid

        public java.lang.String getSid()
      • setSid

        public void setSid​(java.lang.String sid)
      • isForceResume

        public boolean isForceResume()
      • setForceResume

        public void setForceResume​(boolean forceResume)
      • getWelcomeMessage

        public java.lang.String getWelcomeMessage()
        Returns:
        the welcomeMessage
      • setWelcomeMessage

        public void setWelcomeMessage​(java.lang.String welcomeMessage)
        Parameters:
        welcomeMessage - the welcomeMessage to set
      • setClientCredentials

        public void setClientCredentials​(java.util.function.Supplier<ClientCredentials> creds)
                                  throws unlimited.core.util.common.exception.FCException
        Throws:
        unlimited.core.util.common.exception.FCException
      • getRemoteHost

        public java.lang.String getRemoteHost()
      • getRemotePort

        public int getRemotePort()
      • reinitSessionIfNeeded

        public void reinitSessionIfNeeded()
                                   throws unlimited.core.util.common.exception.FCException,
                                          java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException