hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r558158 - in /jakarta/httpcomponents/httpclient/trunk: ./ module-client/src/examples/org/apache/http/examples/client/ module-client/src/main/java/org/apache/http/client/ module-client/src/main/java/org/apache/http/impl/client/ module-client...
Date Fri, 20 Jul 2007 21:33:19 GMT
Author: olegk
Date: Fri Jul 20 14:33:17 2007
New Revision: 558158

URL: http://svn.apache.org/viewvc?view=rev&rev=558158
Log:
HTTPCLIENT-666: Replace HttpState with CredentialsProvier and CookieStore interfaces

Removed:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpState.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAuthentication.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientFormLogin.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java

Modified: jakarta/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Fri Jul 20 14:33:17 2007
@@ -1,5 +1,8 @@
 Changes since release 4.0 Alpha 1
 
+* [HTTPCLIENT-666] Replaced HttpState with CredentialsProvier and CookieStore interfaces

+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-100] revised HttpContext hierarchy
   Contributed by Roland Weber <rolandw at apache.org>
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAuthentication.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAuthentication.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAuthentication.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAuthentication.java
Fri Jul 20 14:33:17 2007
@@ -47,7 +47,7 @@
     public static void main(String[] args) throws Exception {
         DefaultHttpClient httpclient = new DefaultHttpClient();
 
-        httpclient.getState().setCredentials(
+        httpclient.getCredentialsProvider().setCredentials(
                 new AuthScope("localhost", 443), 
                 new UsernamePasswordCredentials("username", "password"));
         

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
Fri Jul 20 14:33:17 2007
@@ -35,10 +35,10 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.client.CookieStore;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.HttpState;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.BasicHttpContext;
@@ -55,7 +55,7 @@
         HttpClient httpclient = new DefaultHttpClient();
 
         // Create a local instance of cookie store
-        CookieStore cookieStore = new HttpState();
+        CookieStore cookieStore = new BasicCookieStore();
         
         // Obtain default HTTP context
         HttpContext defaultContext = httpclient.getDefaultContext();

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientFormLogin.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientFormLogin.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientFormLogin.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientFormLogin.java
Fri Jul 20 14:33:17 2007
@@ -64,7 +64,7 @@
             entity.consumeContent();
         }
         System.out.println("Initial set of cookies:");    
-        Cookie[] cookies = httpclient.getState().getCookies();
+        Cookie[] cookies = httpclient.getCookieStore().getCookies();
         if (cookies.length == 0) {
             System.out.println("None");    
         } else {
@@ -94,7 +94,7 @@
         }
         
         System.out.println("Post logon cookies:");    
-        cookies = httpclient.getState().getCookies();
+        cookies = httpclient.getCookieStore().getCookies();
         if (cookies.length == 0) {
             System.out.println("None");    
         } else {

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
Fri Jul 20 14:33:17 2007
@@ -48,7 +48,7 @@
         
         DefaultHttpClient httpclient = new DefaultHttpClient();
 
-        httpclient.getState().setCredentials(
+        httpclient.getCredentialsProvider().setCredentials(
                 new AuthScope("localhost", 8080), 
                 new UsernamePasswordCredentials("username", "password"));
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
Fri Jul 20 14:33:17 2007
@@ -45,9 +45,10 @@
 import org.apache.http.auth.AuthSchemeRegistry;
 import org.apache.http.client.AuthenticationHandler;
 import org.apache.http.client.ClientRequestDirector;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.HttpState;
 import org.apache.http.client.RedirectHandler;
 import org.apache.http.client.RoutedRequest;
 import org.apache.http.client.methods.HttpUriRequest;
@@ -107,8 +108,11 @@
     /** The authentication handler. */
     private AuthenticationHandler authHandler;
 
-    /** The default HTTP state. */
-    private HttpState defaultState;
+    /** The cookie store. */
+    private CookieStore cookieStore;
+
+    /** The credentials provider. */
+    private CredentialsProvider credsProvider;
 
     /**
      * Creates a new HTTP client.
@@ -154,7 +158,10 @@
     protected abstract AuthenticationHandler createAuthenticationHandler();
 
     
-    protected abstract HttpState createHttpState();
+    protected abstract CookieStore createCookieStore();
+    
+    
+    protected abstract CredentialsProvider createCredentialsProvider();
     
     
     protected abstract void populateContext(HttpContext context);
@@ -271,16 +278,29 @@
     }
 
 
-    public synchronized final HttpState getState() {
-        if (defaultState == null) {
-            defaultState = createHttpState();
+    public synchronized final CookieStore getCookieStore() {
+        if (cookieStore == null) {
+            cookieStore = createCookieStore();
+        }
+        return cookieStore;
+    }
+
+
+    public synchronized void setCookieStore(final CookieStore cookieStore) {
+        this.cookieStore = cookieStore;
+    }
+
+
+    public synchronized final CredentialsProvider getCredentialsProvider() {
+        if (credsProvider == null) {
+            credsProvider = createCredentialsProvider();
         }
-        return defaultState;
+        return credsProvider;
     }
 
 
-    public synchronized void setState(final HttpState state) {
-        defaultState = state;
+    public synchronized void setState(final CredentialsProvider credsProvider) {
+        this.credsProvider = credsProvider;
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
Fri Jul 20 14:33:17 2007
@@ -38,8 +38,9 @@
 import org.apache.http.HttpVersion;
 import org.apache.http.auth.AuthSchemeRegistry;
 import org.apache.http.client.AuthenticationHandler;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.HttpState;
 import org.apache.http.client.RedirectHandler;
 import org.apache.http.client.RoutedRequest;
 import org.apache.http.client.VersionInfo;
@@ -238,8 +239,13 @@
     }
 
 
-    protected HttpState createHttpState() {
-        return new HttpState();
+    protected CookieStore createCookieStore() {
+        return new BasicCookieStore();
+    }
+
+
+    protected CredentialsProvider createCredentialsProvider() {
+        return new BasicCredentialsProvider();
     }
 
 
@@ -252,10 +258,10 @@
                 getCookieSpecs());
         context.setAttribute(
                 ClientContext.COOKIE_STORE, 
-                getState());
+                getCookieStore());
         context.setAttribute(
                 ClientContext.CREDS_PROVIDER, 
-                getState());
+                getCredentialsProvider());
     }
 
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
Fri Jul 20 14:33:17 2007
@@ -41,9 +41,7 @@
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.SchemeRegistry;
-import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
-
 
 
 /**

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java?view=diff&rev=558158&r1=558157&r2=558158
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ThreadSafeClientConnManager.java
Fri Jul 20 14:33:17 2007
@@ -47,12 +47,10 @@
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.HttpRoute;
-import org.apache.http.conn.HttpRoute;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.SchemeRegistry;
 import org.apache.http.conn.params.HttpConnectionManagerParams;
-import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 
 



Mime
View raw message