[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    svn commit: r1026120 -
From:       olegk () apache ! org
Date:       2010-10-21 19:57:32
Message-ID: 20101021195732.EE9132388978 () eris ! apache ! org
[Download RAW message or body]

Author: olegk
Date: Thu Oct 21 19:57:32 2010
New Revision: 1026120

URL: http://svn.apache.org/viewvc?rev=1026120&view=rev
Log:
Fixed examples

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
  httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java


Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -31,6 +31,7 @@ import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
 
 /**
  * A simple example that uses HttpClient to execute an HTTP request against
@@ -56,9 +57,7 @@ public class ClientAuthentication {
         if (entity != null) {
             System.out.println("Response content length: " + \
entity.getContentLength());  }
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
 
         // When HttpClient instance is no longer needed, 
         // shut down the connection manager to ensure

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientChunkEncodedPost.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java \
Thu Oct 21 19:57:32 2010 @@ -35,6 +35,7 @@ import org.apache.http.client.HttpClient
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
 
 /**
  * Example how to use unbuffered chunk-encoded POST request.
@@ -75,9 +76,7 @@ public class ClientChunkEncodedPost {
             System.out.println("Response content length: " + \
resEntity.getContentLength());  System.out.println("Chunked?: " + \
resEntity.isChunked());  }
-        if (resEntity != null) {
-            resEntity.consumeContent();
-        }
+        EntityUtils.consume(resEntity);
 
         // When HttpClient instance is no longer needed, 
         // shut down the connection manager to ensure

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientCustomContext.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java \
Thu Oct 21 19:57:32 2010 @@ -40,6 +40,7 @@ import org.apache.http.impl.client.Basic
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.util.EntityUtils;
 
 
 /**
@@ -79,9 +80,7 @@ public class ClientCustomContext {
         }
         
         // Consume response content
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
         
         System.out.println("----------------------------------------");
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientCustomSSL.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java \
Thu Oct 21 19:57:32 2010 @@ -36,6 +36,7 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
 
 /**
  * This example demonstrates how to create secure connections with a custom SSL
@@ -70,9 +71,7 @@ public class ClientCustomSSL {
         if (entity != null) {
             System.out.println("Response content length: " + \
entity.getContentLength());  }
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
 
         // When HttpClient instance is no longer needed, 
         // shut down the connection manager to ensure

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientEvictExpiredConnections.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java \
Thu Oct 21 19:57:32 2010 @@ -38,6 +38,7 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.util.EntityUtils;
 
 /**
  * Example demonstrating how to evict expired and idle connections
@@ -52,7 +53,7 @@ public class ClientEvictExpiredConnectio
                 new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
         
         ThreadSafeClientConnManager cm = new \
                ThreadSafeClientConnManager(schemeRegistry);
-        cm.setMaxTotalConnections(100);
+        cm.setMaxTotal(100);
         
         HttpClient httpclient = new DefaultHttpClient(cm);
         
@@ -83,9 +84,7 @@ public class ClientEvictExpiredConnectio
             }
             System.out.println("----------------------------------------");
 
-            if (entity != null) {
-                entity.consumeContent();
-            }
+            EntityUtils.consume(entity);
         }
         
         // Sleep 10 sec and let the connection evictor do its job

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientFormLogin.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java \
Thu Oct 21 19:57:32 2010 @@ -38,6 +38,7 @@ import org.apache.http.cookie.Cookie;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
 
 /**
  * A example that demonstrates how HttpClient APIs can be used to perform
@@ -55,9 +56,8 @@ public class ClientFormLogin {
         HttpEntity entity = response.getEntity();
 
         System.out.println("Login form get: " + response.getStatusLine());
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
+
         System.out.println("Initial set of cookies:");
         List<Cookie> cookies = httpclient.getCookieStore().getCookies();
         if (cookies.isEmpty()) {
@@ -83,9 +83,7 @@ public class ClientFormLogin {
         entity = response.getEntity();
 
         System.out.println("Login form get: " + response.getStatusLine());
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
 
         System.out.println("Post logon cookies:");
         cookies = httpclient.getCookieStore().getCookies();

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientInteractiveAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -40,6 +40,7 @@ import org.apache.http.client.protocol.C
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
 
 /**
  * A simple example that uses HttpClient to execute an HTTP request against
@@ -65,9 +66,7 @@ public class ClientInteractiveAuthentica
 
             // Consume response content
             HttpEntity entity = response.getEntity();
-            if (entity != null) {
-                entity.consumeContent();
-            }
+            EntityUtils.consume(entity);
             
             int sc = response.getStatusLine().getStatusCode();
             

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientKerberosAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -162,9 +162,7 @@ public class ClientKerberosAuthenticatio
         System.out.println("----------------------------------------");
         
         // This ensures the connection gets released back to the manager
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
 
         // When HttpClient instance is no longer needed, 
         // shut down the connection manager to ensure

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientMultiThreadedExecution.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java \
Thu Oct 21 19:57:32 2010 @@ -55,7 +55,7 @@ public class ClientMultiThreadedExecutio
         // This connection manager must be used if more than one thread will
         // be using the HttpClient.
         ThreadSafeClientConnManager cm = new \
                ThreadSafeClientConnManager(schemeRegistry);
-        cm.setMaxTotalConnections(100);
+        cm.setMaxTotal(100);
         
         HttpClient httpClient = new DefaultHttpClient(cm);
         

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -37,6 +37,7 @@ import org.apache.http.impl.auth.BasicSc
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.util.EntityUtils;
 
 /**
  * An example of HttpClient can be customized to authenticate 
@@ -82,8 +83,8 @@ public class ClientPreemptiveBasicAuthen
             System.out.println(response.getStatusLine());
             if (entity != null) {
                 System.out.println("Response content length: " + \
                entity.getContentLength());
-                entity.consumeContent();
             }
+            EntityUtils.consume(entity);
         }
         
         // When HttpClient instance is no longer needed, 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -37,6 +37,7 @@ import org.apache.http.impl.auth.DigestS
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.util.EntityUtils;
 
 /**
  * An example of HttpClient can be customized to authenticate 
@@ -86,8 +87,8 @@ public class ClientPreemptiveDigestAuthe
             System.out.println(response.getStatusLine());
             if (entity != null) {
                 System.out.println("Response content length: " + \
                entity.getContentLength());
-                entity.consumeContent();
             }
+            EntityUtils.consume(entity);
         }
         
         // When HttpClient instance is no longer needed, 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examp \
les/org/apache/http/examples/client/ClientProxyAuthentication.java?rev=1026120&r1=1026119&r2=1026120&view=diff
 ==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java \
                (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java \
Thu Oct 21 19:57:32 2010 @@ -33,6 +33,7 @@ import org.apache.http.auth.UsernamePass
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.params.ConnRoutePNames;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
 
 /**
  * A simple example that uses HttpClient to execute an HTTP request 
@@ -67,9 +68,7 @@ public class ClientProxyAuthentication {
         if (entity != null) {
             System.out.println("Response content length: " + \
entity.getContentLength());  }
-        if (entity != null) {
-            entity.consumeContent();
-        }
+        EntityUtils.consume(entity);
         
         // When HttpClient instance is no longer needed, 
         // shut down the connection manager to ensure


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic