當前位置: 首頁>>代碼示例>>Java>>正文


Java CookiePolicy.ACCEPT_ALL屬性代碼示例

本文整理匯總了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.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:28,代碼來源:CookieHttpsClientTest.java

示例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.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:CookieHttpClientTest.java

示例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");
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:22,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:DandreX,項目名稱:MALFriends,代碼行數:37,代碼來源:RequestHelper.java

示例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;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:7,代碼來源:CookieManager.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:HttpOnly.java

示例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();
}
 
開發者ID:MimiReader,項目名稱:mimi-reader,代碼行數:13,代碼來源:HttpClientFactory.java

示例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);
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:11,代碼來源:HttpApiTest.java

示例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);
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:12,代碼來源:WsApiTest.java

示例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);
}
 
開發者ID:bwzz,項目名稱:yyl,代碼行數:10,代碼來源:MyApplication.java

示例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;
}
 
開發者ID:jcricket,項目名稱:gwt-syncproxy,代碼行數:7,代碼來源:CookieServiceTest.java

示例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));
}
 
開發者ID:lemberg,項目名稱:android-project-template,代碼行數:8,代碼來源:DrupalModel.java

示例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));
}
 
開發者ID:lemberg,項目名稱:android-project-template,代碼行數:8,代碼來源:Model.java

示例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;
}
 
開發者ID:yanzhenjie,項目名稱:NoHttp,代碼行數:33,代碼來源:InitializationConfig.java

示例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);
        }
    });
}
 
開發者ID:2fast2fourier,項目名稱:something.apk,代碼行數:14,代碼來源:SomePreferences.java


注:本文中的java.net.CookiePolicy.ACCEPT_ALL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。