hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r534839 - in /jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http: auth/ client/params/ conn/ impl/auth/ impl/client/
Date Thu, 03 May 2007 13:03:42 GMT
Author: olegk
Date: Thu May  3 06:03:41 2007
New Revision: 534839

URL: http://svn.apache.org/viewvc?view=rev&rev=534839
Log:
* Fully initialize the default instances of HttpParams, CookieSpecRegistry, and AuthSchemeRegistry
* Instantiate the default ClientConnectionManager based on the HttpParams content

Added:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
  (with props)
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
  (with props)
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/HttpClientParams.java
      - copied, changed from r534783, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpClientParams.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
  (with props)
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
  (with props)
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
  (with props)
Modified:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthSchemeRegistry.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultHttpClient.java

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthSchemeRegistry.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthSchemeRegistry.java?view=diff&rev=534839&r1=534838&r2=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthSchemeRegistry.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthSchemeRegistry.java
Thu May  3 06:03:41 2007
@@ -65,7 +65,7 @@
      * 
      * @see #getAuthScheme
      */
-    public synchronized void registerAuthScheme(
+    public synchronized void register(
             final String name, 
             final AuthSchemeFactory factory) {
          if (name == null) {
@@ -83,7 +83,7 @@
      * 
      * @param name the identifier of the class to unregister
      */
-    public synchronized void unregisterAuthScheme(final String name) {
+    public synchronized void unregister(final String name) {
          if (name == null) {
              throw new IllegalArgumentException("Name may not be null");
          }

Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java?view=auto&rev=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
Thu May  3 06:03:41 2007
@@ -0,0 +1,58 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.client.params;
+
+public final class AuthPolicy {
+
+    private AuthPolicy() {
+        super();
+    }
+    
+    /**
+     * The NTLM scheme is a proprietary Microsoft Windows Authentication 
+     * protocol (considered to be the most secure among currently supported 
+     * authentication schemes).
+     */
+    public static final String NTLM = "NTLM";
+    
+    /** 
+     * Digest authentication scheme as defined in RFC2617.
+     */
+    public static final String DIGEST = "Digest";
+
+    /** 
+     * Basic authentication scheme as defined in RFC2617 (considered inherently
+     * insecure, but most widely supported)
+     */
+    public static final String BASIC = "Basic";
+    
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/AuthPolicy.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java?view=auto&rev=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
Thu May  3 06:03:41 2007
@@ -0,0 +1,66 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.client.params;
+
+public final class CookiePolicy {
+
+    /**
+     * The policy that provides high degree of compatibilty 
+     * with common cookie management of popular HTTP agents.
+     */
+    public static final String BROWSER_COMPATIBILITY = "compatibility";
+    
+    /** 
+     * The Netscape cookie draft compliant policy. 
+     */
+    public static final String NETSCAPE = "netscape";
+
+    /** 
+     * The RFC 2109 compliant policy. 
+     */
+    public static final String RFC_2109 = "rfc2109";
+
+    /**
+     * The RFC 2965 compliant policy.
+     */
+    public static final String RFC_2965 = "rfc2965";
+
+    /**
+     * The policy that ignores cookies. 
+     */
+    public static final String IGNORE_COOKIES = "ignoreCookies";
+    
+    private CookiePolicy() {
+        super();
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/CookiePolicy.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/HttpClientParams.java
(from r534783, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpClientParams.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/HttpClientParams.java?view=diff&rev=534839&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpClientParams.java&r1=534783&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/HttpClientParams.java&r2=534839
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpClientParams.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/params/HttpClientParams.java
Thu May  3 06:03:41 2007
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java,v
1.7 2004/05/13 04:01:22 mbecke Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -28,27 +28,25 @@
  *
  */
 
-package org.apache.commons.httpclient.params;
+package org.apache.http.client.params;
+
+import org.apache.http.params.HttpParams;
 
 /**
- * This class represents a collection of HTTP protocol parameters applicable to 
- * {@link org.apache.commons.httpclient.HttpClient instances of HttpClient}. 
- * Protocol parameters may be linked together to form a hierarchy. If a particular 
- * parameter value has not been explicitly defined in the collection itself, its 
- * value will be drawn from the parent collection of parameters.
+ * An adaptor for accessing HTTP client parameters in {@link HttpParams}.
  * 
- * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
  * @version $Revision$
  * 
  * @since 3.0
  */
-public class HttpClientParams extends HttpMethodParams {
+public class HttpClientParams {
 
     /**
-     * Sets the timeout in milliseconds used when retrieving an 
-     * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the
-     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}.
+     * Sets the timeout in milliseconds used when retrieving an instance of 
+     * {@link org.apache.http.conn.ManagedClientConnection} from the
+     * {@link org.apache.http.conn.ClientConnectionManager}.
      * <p>
      * This parameter expects a value of type {@link Long}.
      * </p>
@@ -56,14 +54,12 @@
     public static final String CONNECTION_MANAGER_TIMEOUT = "http.connection-manager.timeout";

 
     /**
-     * Defines the default 
-     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
-     * class.
+     * Defines the class name of the default {@link org.apache.http.conn.ClientConnectionManager}
      * <p>
-     * This parameter expects a value of type {@link Class}.
+     * This parameter expects a value of type {@link String}.
      * </p>
      */ 
-    public static final String CONNECTION_MANAGER_CLASS = "http.connection-manager.class";

+    public static final String CONNECTION_MANAGER_FACTORY = "http.connection-manager.factory";

 
     /**
      * Defines whether authentication should be attempted preemptively.
@@ -101,41 +97,29 @@
     public static final String ALLOW_CIRCULAR_REDIRECTS = "http.protocol.allow-circular-redirects";
 
     /**
-     * Creates a new collection of parameters with the collection returned
-     * by {@link #getDefaultParams()} as a parent. The collection will defer
-     * to its parent for a default value if a particular parameter is not 
-     * explicitly set in the collection itself.
-     * 
-     * @see #getDefaultParams()
+     * Defines the name of the cookie specification to be used for HTTP state management.
+     * <p>
+     * This parameter expects a value of type {@link String}.
+     * </p>
      */
-    public HttpClientParams() {
+    public static final String COOKIE_POLICY = "http.protocol.cookie-policy";
+    
+    private HttpClientParams() {
         super();
     }
 
     /**
-     * Creates a new collection of parameters with the given parent. 
-     * The collection will defer to its parent for a default value 
-     * if a particular parameter is not explicitly set in the collection
-     * itself.
-     * 
-     * @param defaults the parent collection to defer to, if a parameter
-     * is not explictly set in the collection itself.
-     *
-     * @see #getDefaultParams()
-     */
-    public HttpClientParams(HttpParams defaults) {
-        super(defaults);
-    }
-
-    /**
      * Returns the timeout in milliseconds used when retrieving an 
      * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the
      * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}.
      * 
      * @return timeout in milliseconds.
      */ 
-    public long getConnectionManagerTimeout() {
-        return getLongParameter(CONNECTION_MANAGER_TIMEOUT, 0);
+    public static long getConnectionManagerTimeout(final HttpParams params) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getLongParameter(CONNECTION_MANAGER_TIMEOUT, 0);
     }
 
     /**
@@ -145,41 +129,25 @@
      * 
      * @param timeout the timeout in milliseconds
      */ 
-    public void setConnectionManagerTimeout(long timeout) {
-        setLongParameter(CONNECTION_MANAGER_TIMEOUT, timeout);
+    public static void setConnectionManagerTimeout(final HttpParams params, long timeout)
{
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setLongParameter(CONNECTION_MANAGER_TIMEOUT, timeout);
     }
 
     /**
-     * Returns the default 
-     * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
-     * class.
-     * @return {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection
manager}
-     * factory class.
-     */ 
-    public Class getConnectionManagerClass() {
-        return (Class) getParameter(CONNECTION_MANAGER_CLASS);
-    }
-
-    /**
-     * Sets {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
-     * class to be used der default.
-     * @param clazz 
-     *  {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}
-     *  factory class.
-     */ 
-    public void setConnectionManagerClass(Class clazz) {
-        setParameter(CONNECTION_MANAGER_CLASS, clazz);
-    }
-    
-    /**
      * Returns <tt>true</tt> if authentication should be attempted preemptively,

      * <tt>false</tt> otherwise.
      * 
      * @return <tt>true</tt> if authentication should be attempted preemptively,
      *   <tt>false</tt> otherwise.
      */
-    public boolean isAuthenticationPreemptive() {
-        return getBooleanParameter(PREEMPTIVE_AUTHENTICATION, false); 
+    public static boolean isAuthenticationPreemptive(final HttpParams params) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getBooleanParameter(PREEMPTIVE_AUTHENTICATION, false); 
     }
 
     /**
@@ -188,24 +156,29 @@
      * @param value <tt>true</tt> if authentication should be attempted preemptively,
      *   <tt>false</tt> otherwise.
      */
-    public void setAuthenticationPreemptive(boolean value) {
-        setBooleanParameter(PREEMPTIVE_AUTHENTICATION, value); 
+    public static void setAuthenticationPreemptive(final HttpParams params, boolean value)
{
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setBooleanParameter(PREEMPTIVE_AUTHENTICATION, value); 
     }
-
-    private static final String[] PROTOCOL_STRICTNESS_PARAMETERS = {
-        REJECT_RELATIVE_REDIRECT,
-        ALLOW_CIRCULAR_REDIRECTS
-    };
-
-
-    public void makeStrict() {
-        super.makeStrict();
-        setParameters(PROTOCOL_STRICTNESS_PARAMETERS, Boolean.TRUE);
+    
+    public static String getCookiePolicy(final HttpParams params) { 
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        String cookiePolicy = (String) params.getParameter(COOKIE_POLICY);
+        if (cookiePolicy == null) {
+            return CookiePolicy.BROWSER_COMPATIBILITY;
+        }
+        return cookiePolicy;
     }
-
-
-    public void makeLenient() {
-        super.makeLenient();
-        setParameters(PROTOCOL_STRICTNESS_PARAMETERS, Boolean.FALSE);
+    
+    public static void setCookiePolicy(final HttpParams params, final String cookiePolicy)
{
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setParameter(COOKIE_POLICY, cookiePolicy);
     }
+
 }

Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java?view=auto&rev=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
Thu May  3 06:03:41 2007
@@ -0,0 +1,48 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn;
+
+import org.apache.http.params.HttpParams;
+
+/**
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @since 4.0
+ */
+public interface ClientConnectionManagerFactory {    
+
+    ClientConnectionManager newInstance(
+            HttpParams params, 
+            SchemeRegistry schemeRegistry);
+
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/ClientConnectionManagerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java?view=auto&rev=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
Thu May  3 06:03:41 2007
@@ -0,0 +1,50 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.auth;
+
+import org.apache.http.auth.AuthScheme;
+import org.apache.http.auth.AuthSchemeFactory;
+import org.apache.http.params.HttpParams;
+
+/**
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @since 4.0
+ */
+public class BasicSchemeFactory implements AuthSchemeFactory {    
+
+    public AuthScheme newInstance(final HttpParams params) {
+        return new BasicScheme();
+    }
+
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/BasicSchemeFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java?view=auto&rev=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
Thu May  3 06:03:41 2007
@@ -0,0 +1,50 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.auth;
+
+import org.apache.http.auth.AuthScheme;
+import org.apache.http.auth.AuthSchemeFactory;
+import org.apache.http.params.HttpParams;
+
+/**
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @since 4.0
+ */
+public class DigestSchemeFactory implements AuthSchemeFactory {    
+
+    public AuthScheme newInstance(final HttpParams params) {
+        return new DigestScheme();
+    }
+
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/auth/DigestSchemeFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultHttpClient.java?view=diff&rev=534839&r1=534838&r2=534839
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultHttpClient.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/DefaultHttpClient.java
Thu May  3 06:03:41 2007
@@ -35,11 +35,16 @@
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpVersion;
 import org.apache.http.auth.AuthSchemeRegistry;
 import org.apache.http.client.HttpState;
 import org.apache.http.client.RoutedRequest;
+import org.apache.http.client.params.AuthPolicy;
+import org.apache.http.client.params.CookiePolicy;
+import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.ClientConnectionManagerFactory;
 import org.apache.http.conn.HttpRoute;
 import org.apache.http.conn.PlainSocketFactory;
 import org.apache.http.conn.Scheme;
@@ -47,10 +52,17 @@
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.cookie.CookieSpecRegistry;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.auth.BasicSchemeFactory;
+import org.apache.http.impl.auth.DigestSchemeFactory;
 import org.apache.http.impl.conn.SingleClientConnManager;
+import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
+import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
+import org.apache.http.impl.cookie.RFC2109SpecFactory;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.RequestConnControl;
 import org.apache.http.protocol.RequestContent;
@@ -99,7 +111,12 @@
 
     
     protected HttpParams createHttpParams() {
-        return new BasicHttpParams();
+        HttpParams params = new BasicHttpParams();
+        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+        HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
+        HttpProtocolParams.setUserAgent(params, "Jakarta-HttpClient/4.0");
+        HttpProtocolParams.setUseExpectContinue(params, true);
+        return params;
     }
 
     
@@ -110,7 +127,29 @@
         registry.register(
                 new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
 
-        return new SingleClientConnManager(getParams(), registry);
+        ClientConnectionManager connManager = null;        
+        
+        HttpParams params = getParams();
+        String className = (String) params.getParameter(
+                HttpClientParams.CONNECTION_MANAGER_FACTORY);
+        
+        if (className != null) {
+            try {
+                Class clazz = Class.forName(className);
+                ClientConnectionManagerFactory factory = 
+                    (ClientConnectionManagerFactory) clazz.newInstance();
+                connManager = factory.newInstance(params, registry);
+            } catch (ClassNotFoundException ex) {
+                throw new IllegalStateException("Invalid class name: " + className);
+            } catch (IllegalAccessException ex) {
+                throw new IllegalAccessError(ex.getMessage());
+            } catch (InstantiationException ex) {
+                throw new InstantiationError(ex.getMessage());
+            }
+        } else {
+            connManager = new SingleClientConnManager(getParams(), registry); 
+        }
+        return connManager;
     }
 
 
@@ -126,12 +165,27 @@
 
     protected AuthSchemeRegistry createAuthSchemeRegistry() {
         AuthSchemeRegistry registry = new AuthSchemeRegistry(); 
+        registry.register(
+                AuthPolicy.BASIC, 
+                new BasicSchemeFactory());
+        registry.register(
+                AuthPolicy.DIGEST, 
+                new DigestSchemeFactory());
         return registry;
     }
 
 
     protected CookieSpecRegistry createCookieSpecRegistry() {
-        CookieSpecRegistry registry = new CookieSpecRegistry(); 
+        CookieSpecRegistry registry = new CookieSpecRegistry();
+        registry.register(
+                CookiePolicy.BROWSER_COMPATIBILITY, 
+                new BrowserCompatSpecFactory());
+        registry.register(
+                CookiePolicy.NETSCAPE, 
+                new NetscapeDraftSpecFactory());
+        registry.register(
+                CookiePolicy.RFC_2109, 
+                new RFC2109SpecFactory());
         return registry;
     }
 



Mime
View raw message