You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/07/17 23:57:42 UTC

cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestGetMethodLocal.java TestStreams.java TestWebappMethods.java TestWebappRedirect.java

olegk       2003/07/17 14:57:42

  Modified:    httpclient/src/examples FormLoginDemo.java PostXML.java
                        UnbufferedPost.java
               httpclient/src/java/org/apache/commons/httpclient/methods
                        EntityEnclosingMethod.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestGetMethodLocal.java TestStreams.java
                        TestWebappMethods.java TestWebappRedirect.java
  Log:
  Removal of references to deprecated methods
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.2       +6 -4      jakarta-commons/httpclient/src/examples/FormLoginDemo.java
  
  Index: FormLoginDemo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/examples/FormLoginDemo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormLoginDemo.java	24 Mar 2003 18:17:33 -0000	1.1
  +++ FormLoginDemo.java	17 Jul 2003 21:57:42 -0000	1.2
  @@ -59,6 +59,7 @@
   
   import org.apache.commons.httpclient.*;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
  +import org.apache.commons.httpclient.cookie.CookieSpec;
   import org.apache.commons.httpclient.methods.*;
   
   /**
  @@ -95,8 +96,9 @@
           // release any connection resources used by the method
           authget.releaseConnection();
           // See if we got any cookies
  -        Cookie[] initcookies = 
  -          client.getState().getCookies(LOGON_SITE, LOGON_PORT, "/", false);
  +        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
  +        Cookie[] initcookies = cookiespec.match(
  +            LOGON_SITE, LOGON_PORT, "/", false, client.getState().getCookies());
           System.out.println("Initial set of cookies:");    
           if (initcookies.length == 0) {
               System.out.println("None");    
  @@ -122,8 +124,8 @@
           // See if we got any cookies
           // The only way of telling whether logon succeeded is 
           // by finding a session cookie
  -        Cookie[] logoncookies = 
  -          client.getState().getCookies(LOGON_SITE, LOGON_PORT, "/", false);
  +        Cookie[] logoncookies = cookiespec.match(
  +            LOGON_SITE, LOGON_PORT, "/", false, client.getState().getCookies());
           System.out.println("Logon cookies:");    
           if (logoncookies.length == 0) {
               System.out.println("None");    
  
  
  
  1.11      +4 -4      jakarta-commons/httpclient/src/examples/PostXML.java
  
  Index: PostXML.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/examples/PostXML.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PostXML.java	25 Feb 2003 23:33:48 -0000	1.10
  +++ PostXML.java	17 Jul 2003 21:57:42 -0000	1.11
  @@ -117,7 +117,7 @@
           // = content length is explicitly specified
           // = chunk-encoding is used
           if (input.length() < Integer.MAX_VALUE) {
  -            post.setRequestContentLength((int)input.length());
  +            post.setRequestContentLength(input.length());
           } else {
               post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
           }
  
  
  
  1.3       +4 -4      jakarta-commons/httpclient/src/examples/UnbufferedPost.java
  
  Index: UnbufferedPost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/examples/UnbufferedPost.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnbufferedPost.java	2 Feb 2003 11:05:19 -0000	1.2
  +++ UnbufferedPost.java	17 Jul 2003 21:57:42 -0000	1.3
  @@ -84,7 +84,7 @@
   
       File file = new File(args[0]);
       httppost.setRequestBody(new FileInputStream(file));
  -    httppost.setRequestContentLength((int)file.length());
  +    httppost.setRequestContentLength(file.length());
   
       client.executeMethod(httppost);
   
  
  
  
  1.23      +6 -6      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- EntityEnclosingMethod.java	15 Jul 2003 12:40:57 -0000	1.22
  +++ EntityEnclosingMethod.java	17 Jul 2003 21:57:42 -0000	1.23
  @@ -97,13 +97,13 @@
        * The content length will be calculated automatically. This implies
        * buffering of the content.
        */
  -    public static final int CONTENT_LENGTH_AUTO = -2;
  +    public static final long CONTENT_LENGTH_AUTO = -2;
   
       /**
        * The request will use chunked transfer encoding. Content length is not
        * calculated and the content is not buffered.<br>
        */
  -    public static final int CONTENT_LENGTH_CHUNKED = -1;
  +    public static final long CONTENT_LENGTH_CHUNKED = -1;
   
       /** LOG object for this class. */
       private static final Log LOG = LogFactory.getLog(EntityEnclosingMethod.class);
  
  
  
  1.12      +4 -6      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestGetMethodLocal.java
  
  Index: TestGetMethodLocal.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestGetMethodLocal.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestGetMethodLocal.java	16 Jul 2003 20:48:28 -0000	1.11
  +++ TestGetMethodLocal.java	17 Jul 2003 21:57:42 -0000	1.12
  @@ -62,8 +62,6 @@
   
   package org.apache.commons.httpclient;
   
  -import java.io.IOException;
  -
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  
  
  
  1.12      +4 -4      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestStreams.java
  
  Index: TestStreams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestStreams.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestStreams.java	8 May 2003 17:33:53 -0000	1.11
  +++ TestStreams.java	17 Jul 2003 21:57:42 -0000	1.12
  @@ -154,7 +154,7 @@
   
       public void testContentLengthInputStream() throws IOException {
           String correct = "1234567890123456";
  -        InputStream in = new ContentLengthInputStream(new ByteArrayInputStream(HttpConstants.getBytes(correct)), 10);
  +        InputStream in = new ContentLengthInputStream(new ByteArrayInputStream(HttpConstants.getBytes(correct)), 10L);
           byte[] buffer = new byte[50];
           int len = in.read(buffer);
           ByteArrayOutputStream out = new ByteArrayOutputStream();
  
  
  
  1.18      +7 -7      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappMethods.java
  
  Index: TestWebappMethods.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappMethods.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TestWebappMethods.java	23 Jun 2003 23:41:39 -0000	1.17
  +++ TestWebappMethods.java	17 Jul 2003 21:57:42 -0000	1.18
  @@ -328,7 +328,7 @@
   		byte[] body = HttpConstants.getContentBytes(bodyStr);
   
           method.setRequestBody(new ByteArrayInputStream(body));
  -        method.setRequestContentLength(body.length);
  +        method.setRequestContentLength((long)body.length);
           try {
               client.executeMethod(method);
           } catch (Throwable t) {
  @@ -399,7 +399,7 @@
           byte [] body = HttpConstants.getContentBytes(bodyStr);
           method.setRequestHeader("Content-Type", "text/plain");
           method.setRequestBody(new ByteArrayInputStream(body));
  -        method.setRequestContentLength(body.length);
  +        method.setRequestContentLength((long)body.length);
           try {
               client.executeMethod(method);
           } catch (Throwable t) {
  @@ -414,7 +414,7 @@
           method.setPath("/" + getWebappContext() + "/body");
           method.setRequestHeader("Content-Type", "text/plain");
           method.setRequestBody(new ByteArrayInputStream(body));
  -        method.setRequestContentLength(body.length);
  +        method.setRequestContentLength((long)body.length);
           try {
               client.executeMethod(method);
           } catch (Throwable t) {
  
  
  
  1.19      +5 -5      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappRedirect.java
  
  Index: TestWebappRedirect.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappRedirect.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestWebappRedirect.java	5 Mar 2003 04:02:57 -0000	1.18
  +++ TestWebappRedirect.java	17 Jul 2003 21:57:42 -0000	1.19
  @@ -229,7 +229,7 @@
                       + getWebappContext() + "/params?foo=bar&bar=foo"));
           byte[] body = HttpConstants.getContentBytes(bodyStr);
           method.setRequestBody(new ByteArrayInputStream(body));
  -        method.setRequestContentLength(body.length);  //unbuffered request
  +        method.setRequestContentLength((long)body.length);  //unbuffered request
           
           try {
               client.executeMethod(method);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org