olegk       2003/07/05 11:43:04

  Modified:    httpclient/src/java/org/apache/commons/httpclient/methods
                        EntityEnclosingMethod.java
                        ExpectContinueMethod.java GetMethod.java
                        MultipartPostMethod.java PostMethod.java
  Log:
  Removed deprecated disk buffering code
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.19      +4 -33     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
  
  Index: EntityEnclosingMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- EntityEnclosingMethod.java        19 Jun 2003 07:54:33 -0000      1.18
  +++ EntityEnclosingMethod.java        5 Jul 2003 18:43:04 -0000       1.19
  @@ -154,35 +154,6 @@
       }
   
       /**
  -     * Constructor specifying a URI and a tempDir.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 2.0
  -     */
  -    public EntityEnclosingMethod(String uri, String tempDir) {
  -        super(uri, tempDir);
  -        setFollowRedirects(false);
  -    }
  -
  -    /**
  -     * Constructor specifying a URI, tempDir and tempFile.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     * @param tempFile file to store temporary data in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 2.0
  -     */
  -    public EntityEnclosingMethod(String uri, String tempDir, String tempFile) {
  -        super(uri, tempDir, tempFile);
  -        setFollowRedirects(false);
  -    }
  -
  -    /**
        * Returns <tt>true</tt> if there is a request body to be sent.
        * 
        * <P>This method must be overwritten by sub-classes that implement
  
  
  
  1.6       +5 -31     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java
  
  Index: ExpectContinueMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExpectContinueMethod.java 6 Apr 2003 22:31:54 -0000       1.5
  +++ ExpectContinueMethod.java 5 Jul 2003 18:43:04 -0000       1.6
  @@ -66,6 +66,7 @@
   import java.io.IOException;
   import org.apache.commons.httpclient.HttpConnection;
   import org.apache.commons.httpclient.HttpException;
  +import org.apache.commons.httpclient.HttpMethodBase;
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -87,7 +88,7 @@
    * @since 2.0beta1
    */
   
  -public abstract class ExpectContinueMethod extends GetMethod {
  +public abstract class ExpectContinueMethod extends HttpMethodBase {
       
       /** This flag specifies whether "expect: 100-continue" handshake is
        * to be used prior to sending the request body */
  @@ -114,33 +115,6 @@
        */
       public ExpectContinueMethod(String uri) {
           super(uri);
  -    }
  -
  -    /**
  -     * Constructor specifying a URI and a tempDir.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 2.0
  -     */
  -    public ExpectContinueMethod(String uri, String tempDir) {
  -        super(uri, tempDir);
  -    }
  -
  -    /**
  -     * Constructor specifying a URI, tempDir and tempFile.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     * @param tempFile file to store temporary data in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 2.0
  -     */
  -    public ExpectContinueMethod(String uri, String tempDir, String tempFile) {
  -        super(uri, tempDir, tempFile);
       }
   
       /**
  
  
  
  1.25      +4 -274    
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java
  
  Index: GetMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- GetMethod.java    29 Apr 2003 22:18:08 -0000      1.24
  +++ GetMethod.java    5 Jul 2003 18:43:04 -0000       1.25
  @@ -63,18 +63,7 @@
   
   package org.apache.commons.httpclient.methods;
   
  -import java.io.File;
  -import java.io.FileInputStream;
  -import java.io.FileOutputStream;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.OutputStream;
  -import java.net.URLEncoder;
  -
  -import org.apache.commons.httpclient.HttpConnection;
  -import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpMethodBase;
  -import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -127,40 +116,6 @@
       /** Log object for this class. */
       private static final Log LOG = LogFactory.getLog(GetMethod.class);
   
  -    /** 
  -     * Temporary directory.
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private static final String TEMP_DIR = "temp/";
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /** 
  -     * File which contains the buffered data.
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private File fileData;
  -
  -    /** 
  -     * Temporary directory to use.
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private String tempDir = TEMP_DIR;
  -
  -    /** 
  -     * Temporary file to use.
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private String tempFile = null;
  -
  -    /** 
  -     * By default, the get method will buffer read data to the memory.
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private boolean useDisk = false;
  -
  -
       // ----------------------------------------------------------- Constructors
   
       /**
  @@ -185,86 +140,6 @@
           setFollowRedirects(true);
       }
   
  -    /**
  -     * Constructor.
  -     * 
  -     * @param path the path to request
  -     * @param tempDir the directory in which to store temporary files
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public GetMethod(String path, String tempDir) {
  -        super(path);
  -        LOG.trace("enter GetMethod(String, String)");
  -        setUseDisk(true);
  -        setTempDir(tempDir);
  -        setFollowRedirects(true);
  -    }
  -
  -    /**
  -     * Constructor.
  -     * 
  -     * @param path the path to request
  -     * @param tempDir the directory in which to store temporary files
  -     * @param tempFile the file (under tempDir) to buffer contents to
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public GetMethod(String path, String tempDir, String tempFile) {
  -        super(path);
  -        LOG.trace("enter GetMethod(String, String, String)");
  -        setUseDisk(true);
  -        setTempDir(tempDir);
  -        setTempFile(tempFile);
  -        setFollowRedirects(true);
  -    }
  -
  -    /**
  -     * Constructor.
  -     * 
  -     * @param path the path to request
  -     * @param fileData the file to buffer contents to
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public GetMethod(String path, File fileData) {
  -        this(path);
  -        LOG.trace("enter GetMethod(String, File)");
  -        useDisk = true;
  -        this.fileData = fileData;
  -        setFollowRedirects(true);
  -    }
  -
  -    //~ Methods ································································
  -
  -    /**
  -     * File data setter.
  -     * 
  -     * @param fileData the file to buffer data to
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public void setFileData(File fileData) {
  -        checkNotUsed();
  -        this.fileData = fileData;
  -    }
  -
  -    /**
  -     * File data getter.
  -     * 
  -     * @return the file being used for buffering data
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public File getFileData() {
  -        return fileData;
  -    }
  -
       // --------------------------------------------------------- Public Methods
   
       /**
  @@ -278,86 +153,9 @@
           return "GET";
       }
   
  -    /**
  -     * Temporary directory setter.
  -     * 
  -     * @param tempDir New value of tempDir
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public void setTempDir(String tempDir) {
  -        checkNotUsed();
  -        this.tempDir = tempDir;
  -        setUseDisk(true);
  -    }
  -
  -    /**
  -     * Temporary directory getter.
  -     * 
  -     * @return the current temporary directory
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public String getTempDir() {
  -        return tempDir;
  -    }
  -
  -    /**
  -     * Temporary file setter.
  -     * 
  -     * @param tempFile New value of tempFile
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public void setTempFile(String tempFile) {
  -        checkNotUsed();
  -        this.tempFile = tempFile;
  -    }
  -
  -    /**
  -     * Temporary file getter.
  -     * 
  -     * @return the current temporary file
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public String getTempFile() {
  -        return tempFile;
  -    }
  -
       // ------------------------------------------------------------- Properties
   
       /**
  -     * Buffer the response in a file or not. The default is false.
  -     * 
  -     * @param useDisk If true the entire response will be buffered in a
  -     *        temporary file.
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public void setUseDisk(boolean useDisk) {
  -        checkNotUsed();
  -        this.useDisk = useDisk;
  -    }
  -
  -    /**
  -     * Tells if the response will be buffered in a file.
  -     * 
  -     * @return true if the response will be buffered
  -     * 
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public boolean getUseDisk() {
  -        return useDisk;
  -    }
  -
  -    /**
        * Override recycle to reset redirects default.
        * 
        * @since 1.0
  @@ -366,75 +164,7 @@
           LOG.trace("enter GetMethod.recycle()");
   
           super.recycle();
  -        this.fileData = null;
           setFollowRedirects(true);
       }
   
  -    // ----------------------------------------------------- HttpMethod Methods
  -
  -    /**
  -     * Overrides method in [EMAIL PROTECTED] HttpMethodBase} to write data to the
  -     * appropriate buffer.
  -     * 
  -     * @param state the shared http state
  -     * @param conn the connection to read data from
  -     * 
  -     * @throws IOException when there are problems reading from the connection
  -     * @throws HttpException when a protocol error occurs or state is invalid
  -     * @since 2.0
  -     */
  -    protected void readResponseBody(HttpState state, HttpConnection conn)
  -    throws IOException, HttpException {
  -        LOG.trace("enter GetMethod.readResponseBody(HttpState, HttpConnection)");
  -
  -        super.readResponseBody(state, conn);
  -
  -        OutputStream out = null;
  -        if (useDisk) {
  -            out = new FileOutputStream(createTempFile());
  -            InputStream in = getResponseBodyAsStream();
  -            byte[] buffer = new byte[10000];
  -            int len ;
  -            while ((len = in.read(buffer)) > 0) {
  -                out.write(buffer, 0, len);
  -            }
  -            in.close();
  -            out.close();
  -            setResponseStream(new FileInputStream(createTempFile()));
  -        }
  -    }
  -
  -    /**
  -     * Returns the file buffer, creating it if necessary. The created file is
  -     * deleted when the VM exits.
  -     * @return Temporary file to hold the data buffer.
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     */
  -    private File createTempFile() {
  -        if (fileData == null) {
  -            // Create a temporary file on the HD
  -            File dir = new File(tempDir);
  -            dir.deleteOnExit();
  -            dir.mkdirs();
  -            String tempFileName = null;
  -            if (tempFile == null) {
  -                String encodedPath = URLEncoder.encode(getPath());
  -                int length = encodedPath.length();
  -                if (length > 200) {
  -                    encodedPath =
  -                        encodedPath.substring(length - 190, length);
  -                }
  -                tempFileName = System.currentTimeMillis() + "-"
  -                    + encodedPath + ".tmp";
  -            } else {
  -                tempFileName = tempFile;
  -            }
  -            fileData = new File(tempDir, tempFileName);
  - 
  -            fileData = new File(tempDir, tempFileName);
  -            fileData.deleteOnExit();
  -        }
  -        return fileData;
  -    }
   }
  
  
  
  1.18      +3 -24     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java
  
  Index: MultipartPostMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MultipartPostMethod.java  7 Apr 2003 19:23:36 -0000       1.17
  +++ MultipartPostMethod.java  5 Jul 2003 18:43:04 -0000       1.18
  @@ -119,27 +119,6 @@
       }
   
       /**
  -     * Constructor specifying a URI and tempDir.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     */
  -    public MultipartPostMethod(String uri, String tempDir) {
  -        super(uri, tempDir);
  -    }
  -
  -    /**
  -     * Constructor specifying a URI, tempDir and tempFile.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     * @param tempFile file to store temporary data in
  -     */
  -    public MultipartPostMethod(String uri, String tempDir, String tempFile) {
  -        super(uri, tempDir, tempFile);
  -    }
  -
  -    /**
        * Returns <tt>true</tt> 
        * 
        * @return <tt>true</tt>
  
  
  
  1.46      +4 -31     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java
  
  Index: PostMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- PostMethod.java   23 Jun 2003 23:41:40 -0000      1.45
  +++ PostMethod.java   5 Jul 2003 18:43:04 -0000       1.46
  @@ -142,33 +142,6 @@
           super(uri);
       }
   
  -    /**
  -     * Constructor specifying a URI and a tempDir.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public PostMethod(String uri, String tempDir) {
  -        super(uri, tempDir);
  -    }
  -
  -    /**
  -     * Constructor specifying a URI, tempDir and tempFile.
  -     *
  -     * @param uri either an absolute or relative URI
  -     * @param tempDir directory to store temp files in
  -     * @param tempFile file to store temporary data in
  -     *
  -     * @deprecated the client is responsible for disk I/O
  -     * @since 1.0
  -     */
  -    public PostMethod(String uri, String tempDir, String tempFile) {
  -        super(uri, tempDir, tempFile);
  -    }
  -
       // ----------------------------------------------------- Instance Methods
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to