1 /* 2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/HttpClientParams.java $ 3 * $Revision: 659595 $ 4 * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $ 5 * 6 * ==================================================================== 7 * 8 * Licensed to the Apache Software Foundation (ASF) under one or more 9 * contributor license agreements. See the NOTICE file distributed with 10 * this work for additional information regarding copyright ownership. 11 * The ASF licenses this file to You under the Apache License, Version 2.0 12 * (the "License"); you may not use this file except in compliance with 13 * the License. You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 * ==================================================================== 23 * 24 * This software consists of voluntary contributions made by many 25 * individuals on behalf of the Apache Software Foundation. For more 26 * information on the Apache Software Foundation, please see 27 * <http://www.apache.org/>. 28 * 29 */ 30 31 package org.apache.http.client.params; 32 33 import org.apache.http.params.HttpParams; 34 35 /** 36 * An adaptor for accessing HTTP client parameters in {@link HttpParams}. 37 * 38 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a> 39 * 40 * @version $Revision: 659595 $ 41 * 42 * @since 4.0 43 */ 44 public class HttpClientParams { 45 46 private HttpClientParams() { 47 super(); 48 } 49 50 public static boolean isRedirecting(final HttpParams params) { 51 if (params == null) { 52 throw new IllegalArgumentException("HTTP parameters may not be null"); 53 } 54 return params.getBooleanParameter 55 (ClientPNames.HANDLE_REDIRECTS, true); 56 } 57 58 public static void setRedirecting(final HttpParams params, boolean value) { 59 if (params == null) { 60 throw new IllegalArgumentException("HTTP parameters may not be null"); 61 } 62 params.setBooleanParameter 63 (ClientPNames.HANDLE_REDIRECTS, value); 64 } 65 66 public static boolean isAuthenticating(final HttpParams params) { 67 if (params == null) { 68 throw new IllegalArgumentException("HTTP parameters may not be null"); 69 } 70 return params.getBooleanParameter 71 (ClientPNames.HANDLE_AUTHENTICATION, true); 72 } 73 74 public static void setAuthenticating(final HttpParams params, boolean value) { 75 if (params == null) { 76 throw new IllegalArgumentException("HTTP parameters may not be null"); 77 } 78 params.setBooleanParameter 79 (ClientPNames.HANDLE_AUTHENTICATION, value); 80 } 81 82 public static String getCookiePolicy(final HttpParams params) { 83 if (params == null) { 84 throw new IllegalArgumentException("HTTP parameters may not be null"); 85 } 86 String cookiePolicy = (String) 87 params.getParameter(ClientPNames.COOKIE_POLICY); 88 if (cookiePolicy == null) { 89 return CookiePolicy.BEST_MATCH; 90 } 91 return cookiePolicy; 92 } 93 94 public static void setCookiePolicy(final HttpParams params, final String cookiePolicy) { 95 if (params == null) { 96 throw new IllegalArgumentException("HTTP parameters may not be null"); 97 } 98 params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy); 99 } 100 101 } 102