当前位置: 首页>>代码示例>>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;未经允许,请勿转载。