本文整理汇总了Java中java.net.CookiePolicy.ACCEPT_ALL属性的典型用法代码示例。如果您正苦于以下问题:Java CookiePolicy.ACCEPT_ALL属性的具体用法?Java CookiePolicy.ACCEPT_ALL怎么用?Java CookiePolicy.ACCEPT_ALL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.net.CookiePolicy
的用法示例。
在下文中一共展示了CookiePolicy.ACCEPT_ALL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doClientSide
void doClientSide() throws Exception {
// Wait for server to get started.
while (!serverReady) {
Thread.sleep(50);
}
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}});
URL url = new URL("https://localhost:" + serverPort +"/");
// Run without a CookieHandler first
InputStream in = url.openConnection().getInputStream();
while (in.read() != -1); // read response body so connection can be reused
// Set a CookeHandler and retest using the HttpClient from the KAC
CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
in = url.openConnection().getInputStream();
while (in.read() != -1);
if (manager.getCookieStore().getCookies().isEmpty()) {
throw new RuntimeException("Failed: No cookies in the cookie Handler.");
}
}
示例2: CookieHttpClientTest
CookieHttpClientTest() throws Exception {
/* start the server */
ss = new ServerSocket(0);
(new Thread(this)).start();
URL url = new URL("http://localhost:" + ss.getLocalPort() +"/");
// Run without a CookieHandler first
InputStream in = url.openConnection().getInputStream();
while (in.read() != -1); // read response body so connection can be reused
// Set a CookeHandler and retest using the HttpClient from the KAC
CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
in = url.openConnection().getInputStream();
while (in.read() != -1);
if (manager.getCookieStore().getCookies().isEmpty()) {
throw new RuntimeException("Failed: No cookies in the cookie Handler.");
}
}
示例3: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
android.webkit.CookieManager.getInstance().setAcceptCookie(true);
CookieManager cookieManager = new CookieManager(new PersistentCookieStore(getApplicationContext()), CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
new APITask(new APICallback() {
@Override
public void r(String result) {
if (result.length() != 0) {
Intent queueList = new Intent(MainActivity.this, QueueListActivity.class);
startActivity(queueList);
} else {
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
}
}).execute("method", "userData");
}
示例4: getRequestQueue
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private static RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.setRedirectHandler(new DefaultRedirectHandler() {
@Override
public boolean isRedirectRequested(HttpResponse response,
HttpContext context) {
boolean isRedirect = super.isRedirectRequested(
response, context);
if (!isRedirect) {
int responseCode = response.getStatusLine()
.getStatusCode();
if (responseCode == 301 || responseCode == 302) {
return true;
}
}
return isRedirect;
}
});
httpClient.setCookieStore(new BasicCookieStore());
HttpStack httpStack = new HttpClientStack(httpClient);
mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance()
.getApplicationContext(), httpStack);
} else {
HttpURLConnection.setFollowRedirects(true);
CookieManager manager = new CookieManager(null,
CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance()
.getApplicationContext());
}
}
return mRequestQueue;
}
示例5: getCookieManager
private static java.net.CookieManager getCookieManager() {
if (mCookieManager == null) {
mCookieManager = new java.net.CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(mCookieManager);
}
return mCookieManager;
}
示例6: populateCookieStore
void populateCookieStore(URI uri)
throws IOException {
CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cm);
Map<String,List<String>> header = new HashMap<>();
List<String> values = new ArrayList<>();
values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path="
+ URI_PATH +"; HttpOnly");
values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH);
header.put("Set-Cookie", values);
cm.put(uri, header);
}
示例7: init
public void init() {
final Cache cache = new Cache(MimiUtil.getInstance().getCacheDir(), MAX_CACHE_SIZE);
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
cookieStore = new PersistentCookieStore(MimiApplication.getInstance());
cookieHandler = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
builder.cache(cache)
.cookieJar(new JavaNetCookieJar(cookieHandler))
.connectTimeout(30, TimeUnit.SECONDS);
okHttpClient = builder.build();
}
示例8: setUp
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
Intent intent = new Intent();
setActivityIntent(intent);
mActivity = getActivity();
android.webkit.CookieManager.getInstance().setAcceptCookie(true);
CookieManager cookieManager = new CookieManager(new PersistentCookieStore(mActivity.getApplicationContext()), CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
}
示例9: setUp
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
Intent intent = new Intent();
intent.putExtra("queue", "Test Queue Please Ignore");
setActivityIntent(intent);
mActivity = getActivity();
android.webkit.CookieManager.getInstance().setAcceptCookie(true);
CookieManager cookieManager = new CookieManager(new PersistentCookieStore(mActivity.getApplicationContext()), CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
}
示例10: onCreate
@Override
public void onCreate() {
super.onCreate();
application = this;
CrashHandler.getInstance().init(this);
CookieManager cookieManager = new CookieManager(PersistentCookieStore.getInstance(this),
CookiePolicy.ACCEPT_ALL);
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
}
示例11: getAsyncService
protected CookieServiceAsync getAsyncService() {
CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
CookieServiceAsync cookieService = SyncProxy.createProxy(
CookieServiceAsync.class,
new ProxySettings().setCookieManager(cm));
return cookieService;
}
示例12: createNewQueue
@NonNull
private RequestQueue createNewQueue(@NonNull final Context context) {
CookieManager cmrCookieMan = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cmrCookieMan);
final VolleyHelperFactory.IVolleyHelper helper = VolleyHelperFactory.newHelper();
return newRequestQueue(context, helper.createHttpStack(context));
}
示例13: createNewQueue
private RequestQueue createNewQueue(Context context) {
cookieStore = new HURLCookieStore(context);
CookieManager cmrCookieMan = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cmrCookieMan);
final VolleyHelperFactory.IVolleyHelper helper = VolleyHelperFactory.newHelper();
return newRequestQueue(context, helper.createHttpStack(context));
}
示例14: InitializationConfig
private InitializationConfig(Builder builder) {
this.mContext = builder.mContext;
this.mConnectTimeout = builder.mConnectTimeout;
this.mReadTimeout = builder.mReadTimeout;
this.mRetryCount = builder.mRetryCount;
this.mSSLSocketFactory = builder.mSSLSocketFactory;
if (this.mSSLSocketFactory == null)
this.mSSLSocketFactory = SSLUtils.defaultSSLSocketFactory();
this.mHostnameVerifier = builder.mHostnameVerifier;
if (this.mHostnameVerifier == null)
this.mHostnameVerifier = SSLUtils.defaultHostnameVerifier();
this.mHeaders = builder.mHeaders;
this.mParams = builder.mParams;
mCookieStore = builder.mCookieStore;
if (mCookieStore == null)
mCookieStore = new DBCookieStore(mContext);
this.mCookieManager = new CookieManager(mCookieStore, CookiePolicy.ACCEPT_ALL);
this.mCacheStore = builder.mCacheStore;
if (this.mCacheStore == null)
this.mCacheStore = new DBCacheStore(mContext);
this.mNetworkExecutor = builder.mNetworkExecutor;
if (this.mNetworkExecutor == null)
this.mNetworkExecutor = new URLConnectionNetworkExecutor();
this.mInterceptor = builder.mInterceptor;
}
示例15: init
public synchronized static void init(Context context){
cookieStore = new PersistentCookieStore(context.getApplicationContext());
cookieManager = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
CookieManager.setDefault(cookieManager);
preferenceStore = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
updatePreferences(preferenceStore);
preferenceStore.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updatePreferences(sharedPreferences);
}
});
}