1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.apache.http.client.params;
28
29 import org.apache.http.annotation.Immutable;
30
31 import org.apache.http.params.HttpConnectionParams;
32 import org.apache.http.params.HttpParams;
33
34
35
36
37
38
39 @Immutable
40 public class HttpClientParams {
41
42 private HttpClientParams() {
43 super();
44 }
45
46 public static boolean isRedirecting(final HttpParams params) {
47 if (params == null) {
48 throw new IllegalArgumentException("HTTP parameters may not be null");
49 }
50 return params.getBooleanParameter
51 (ClientPNames.HANDLE_REDIRECTS, true);
52 }
53
54 public static void setRedirecting(final HttpParams params, boolean value) {
55 if (params == null) {
56 throw new IllegalArgumentException("HTTP parameters may not be null");
57 }
58 params.setBooleanParameter
59 (ClientPNames.HANDLE_REDIRECTS, value);
60 }
61
62 public static boolean isAuthenticating(final HttpParams params) {
63 if (params == null) {
64 throw new IllegalArgumentException("HTTP parameters may not be null");
65 }
66 return params.getBooleanParameter
67 (ClientPNames.HANDLE_AUTHENTICATION, true);
68 }
69
70 public static void setAuthenticating(final HttpParams params, boolean value) {
71 if (params == null) {
72 throw new IllegalArgumentException("HTTP parameters may not be null");
73 }
74 params.setBooleanParameter
75 (ClientPNames.HANDLE_AUTHENTICATION, value);
76 }
77
78 public static String getCookiePolicy(final HttpParams params) {
79 if (params == null) {
80 throw new IllegalArgumentException("HTTP parameters may not be null");
81 }
82 String cookiePolicy = (String)
83 params.getParameter(ClientPNames.COOKIE_POLICY);
84 if (cookiePolicy == null) {
85 return CookiePolicy.BEST_MATCH;
86 }
87 return cookiePolicy;
88 }
89
90 public static void setCookiePolicy(final HttpParams params, final String cookiePolicy) {
91 if (params == null) {
92 throw new IllegalArgumentException("HTTP parameters may not be null");
93 }
94 params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy);
95 }
96
97
98
99
100
101
102 public static void setConnectionManagerTimeout(final HttpParams params, long timeout) {
103 if (params == null) {
104 throw new IllegalArgumentException("HTTP parameters may not be null");
105 }
106 params.setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, timeout);
107 }
108
109
110
111
112
113
114
115
116
117
118 public static long getConnectionManagerTimeout(final HttpParams params) {
119 if (params == null) {
120 throw new IllegalArgumentException("HTTP parameters may not be null");
121 }
122 Long timeout = (Long) params.getParameter(ClientPNames.CONN_MANAGER_TIMEOUT);
123 if (timeout != null) {
124 return timeout.longValue();
125 }
126 return HttpConnectionParams.getConnectionTimeout(params);
127 }
128
129 }