Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * ====================================================================
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ====================================================================
19 *
20 * This software consists of voluntary contributions made by many
21 * individuals on behalf of the Apache Software Foundation. For more
22 * information on the Apache Software Foundation, please see
23 * <http://www.apache.org/>.
24 *
25 */
27 package ch.boye.httpclientandroidlib.client.params;
29 import ch.boye.httpclientandroidlib.annotation.Immutable;
31 import ch.boye.httpclientandroidlib.params.HttpParams;
33 /**
34 * An adaptor for manipulating HTTP client parameters in {@link HttpParams}.
35 *
36 * @since 4.0
37 */
38 @Immutable
39 public class HttpClientParams {
41 private HttpClientParams() {
42 super();
43 }
45 public static boolean isRedirecting(final HttpParams params) {
46 if (params == null) {
47 throw new IllegalArgumentException("HTTP parameters may not be null");
48 }
49 return params.getBooleanParameter
50 (ClientPNames.HANDLE_REDIRECTS, true);
51 }
53 public static void setRedirecting(final HttpParams params, boolean value) {
54 if (params == null) {
55 throw new IllegalArgumentException("HTTP parameters may not be null");
56 }
57 params.setBooleanParameter
58 (ClientPNames.HANDLE_REDIRECTS, value);
59 }
61 public static boolean isAuthenticating(final HttpParams params) {
62 if (params == null) {
63 throw new IllegalArgumentException("HTTP parameters may not be null");
64 }
65 return params.getBooleanParameter
66 (ClientPNames.HANDLE_AUTHENTICATION, true);
67 }
69 public static void setAuthenticating(final HttpParams params, boolean value) {
70 if (params == null) {
71 throw new IllegalArgumentException("HTTP parameters may not be null");
72 }
73 params.setBooleanParameter
74 (ClientPNames.HANDLE_AUTHENTICATION, value);
75 }
77 public static String getCookiePolicy(final HttpParams params) {
78 if (params == null) {
79 throw new IllegalArgumentException("HTTP parameters may not be null");
80 }
81 String cookiePolicy = (String)
82 params.getParameter(ClientPNames.COOKIE_POLICY);
83 if (cookiePolicy == null) {
84 return CookiePolicy.BEST_MATCH;
85 }
86 return cookiePolicy;
87 }
89 public static void setCookiePolicy(final HttpParams params, final String cookiePolicy) {
90 if (params == null) {
91 throw new IllegalArgumentException("HTTP parameters may not be null");
92 }
93 params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy);
94 }
96 }