当前位置: 首页>>代码示例>>Java>>正文


Java CookieManager.setCookiePolicy方法代码示例

本文整理汇总了Java中java.net.CookieManager.setCookiePolicy方法的典型用法代码示例。如果您正苦于以下问题:Java CookieManager.setCookiePolicy方法的具体用法?Java CookieManager.setCookiePolicy怎么用?Java CookieManager.setCookiePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.CookieManager的用法示例。


在下文中一共展示了CookieManager.setCookiePolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _getClient

import java.net.CookieManager; //导入方法依赖的package包/类
private static OkHttpClientImpl _getClient(CookieHandler cookieHandler) {

        OkHttpClientImpl okHttpClient = new OkHttpClientImpl();
        //okHttpClient.setConnectTimeout(SET_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
        //okHttpClient.setReadTimeout(SET_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
        //okHttpClient.setWriteTimeout(SET_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
        if (cookieHandler == null) {
            CookieManager cookieManager = new CookieManager();
            cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_NONE);
            okHttpClient._setCookieHandler(cookieManager);
        } else {
            okHttpClient._setCookieHandler(cookieHandler);
        }

        return okHttpClient;
    }
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:17,代码来源:HttpUtil.java

示例2: post

import java.net.CookieManager; //导入方法依赖的package包/类
Call post(Callback callback) throws IOException {
    OkHttpClient client = getUnsafeOkHttpClient();
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    client.setCookieHandler(cookieManager);
    RequestBody requestBody = new FormEncodingBuilder()
            .add("user_id", NetId)
            .add("user_password", password)
            .build();
    Request request = new Request.Builder()
            .url("https://studentmaintenance.webapps.snu.edu.in/students/public/studentslist/studentslist/loginauth")
            .post(requestBody)
            .build();
    Call call = client.newCall(request);
    call.enqueue(callback);
    return call;
}
 
开发者ID:anuragsai97,项目名称:Library-Token-Automation,代码行数:18,代码来源:LoginActivity.java

示例3: tstGetPost

import java.net.CookieManager; //导入方法依赖的package包/类
public void tstGetPost() throws Exception {
  String urlSource = "http://localhost:8080/beige-accounting-web/secure/main.jsp";
  String urlBase = urlSource.substring(0, urlSource.indexOf("secure") - 1);
  assertEquals("http://localhost:8080/beige-accounting-web", urlBase);
  CookieManager cookieManager = new CookieManager();
  cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
  CookieHandler.setDefault(cookieManager);
  URL url = new URL(urlSource);
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("userName", "admin");
  params.put("userPass", "admin");
  params.put("authMethod", "form");
  params.put("urlBase", urlBase);
  params.put("authUrl", urlBase + "/secure/j_security_check");
  params.put("authUserName", "j_username");
  params.put("authUserPass", "j_password");
  params.put("urlSource", urlSource);
  tstAuthGet(url, params, cookieManager); //either Get or Post for test allowed
  urlSource = "http://localhost:8080/beige-accounting-web/secure/sendEntities";
  params.put("urlSource", urlSource);
  //url = new URL(urlSource);
  //tstAuthPost(url, params, cookieManager);
}
 
开发者ID:demidenko05,项目名称:beige-software,代码行数:24,代码来源:HttpURLConnectionTest.java

示例4: setup

import java.net.CookieManager; //导入方法依赖的package包/类
private static void setup() {
    baseUrlManager = new BaseUrlManager(UrlConstants.SKS1_BASE);
    okHttpClient = new OkHttpClient();
    cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    okHttpClient.setCookieHandler(cookieManager);
    okHttpClient.setConnectTimeout(5, TimeUnit.SECONDS);
    okHttpClient.setReadTimeout(5, TimeUnit.SECONDS);
    okHttpClient.setWriteTimeout(5, TimeUnit.SECONDS);
    okHttpClient.interceptors().add(new HandlerResponseInterceptor());
    retrofit = new Retrofit.Builder()
            .baseUrl(baseUrlManager)
            .client(okHttpClient)
            .addConverterFactory(new DocumentConverterFactory())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
    service = retrofit.create(ConnectionService.class);
}
 
开发者ID:y3seker,项目名称:EgeYemekhaneMobil,代码行数:19,代码来源:RetrofitManager.java

示例5: apiInit

import java.net.CookieManager; //导入方法依赖的package包/类
public static void apiInit() {
    try {
        CookieManager cookieManager = new CookieManager();
        cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .cookieJar(new JavaNetCookieJar(cookieManager))
        .build();
        
        retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(okHttpClient)
        .addConverterFactory(GsonConverterFactory.create())
        .build();
        
        // Service setup
        apiService = retrofit.create(CodenvyApiService.class);
        } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:PathriK,项目名称:CodenvyDownload-DEPRECATED,代码行数:21,代码来源:CodenvyClient.java

示例6: provideHttpClient

import java.net.CookieManager; //导入方法依赖的package包/类
OkHttpClient provideHttpClient() {
    OkHttpClient.Builder builder = new OkHttpClient().newBuilder()
            .connectTimeout(30, TimeUnit.SECONDS);


    builder.addInterceptor(new KinopoiskRequestInterceptor());

    // Log http requests on debug
    if (BuildConfig.DEBUG) {
        //logging interceptor should be last interceptor in chain
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

        builder.addInterceptor(loggingInterceptor);
    }

    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    builder.cookieJar(new JavaNetCookieJar(cookieManager));

    return builder.build();
}
 
开发者ID:x1unix,项目名称:Avi,代码行数:23,代码来源:NetworkApiFactory.java

示例7: OkNet

import java.net.CookieManager; //导入方法依赖的package包/类
private OkNet() {
    OkHttpClient.Builder builder = client.newBuilder();

    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_NONE);
    builder.cookieJar(new JavaNetCookieJar(cookieManager));
    builder.hostnameVerifier(new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    });

    builder.connectTimeout(10, TimeUnit.SECONDS)
            .readTimeout(30, TimeUnit.SECONDS)
            .writeTimeout(20, TimeUnit.SECONDS);

    client = builder.build();
}
 
开发者ID:Jhanay,项目名称:OkNet,代码行数:20,代码来源:OkNet.java

示例8: Builder

import java.net.CookieManager; //导入方法依赖的package包/类
/**
 * Creates an instance of the builder with a base URL and 2 custom builders.
 *
 * @param httpClientBuilder the builder to build an {@link OkHttpClient}.
 * @param retrofitBuilder the builder to build a {@link Retrofit}.
 */
public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder) {
    if (httpClientBuilder == null) {
        throw new IllegalArgumentException("httpClientBuilder == null");
    }
    if (retrofitBuilder == null) {
        throw new IllegalArgumentException("retrofitBuilder == null");
    }
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    customHeadersInterceptor = new CustomHeadersInterceptor();
    // Set up OkHttp client
    this.httpClientBuilder = httpClientBuilder
            .cookieJar(new JavaNetCookieJar(cookieManager))
            .readTimeout(60, TimeUnit.SECONDS)
            .addInterceptor(new RequestIdHeaderInterceptor())
            .addInterceptor(new BaseUrlHandler());
    this.retrofitBuilder = retrofitBuilder;
    this.loggingInterceptor = new LoggingInterceptor(LogLevel.NONE);
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:26,代码来源:RestClient.java

示例9: initCookieManager

import java.net.CookieManager; //导入方法依赖的package包/类
public static void initCookieManager() {

        CookieHandler cookieHandler = CookieHandler.getDefault();

        if (cookieHandler == null) {
            // CookieStore cookieStore = CookieStoreHolder.initInMemoryCookieStore();
            // CookieManager cm = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
            CookieManager cm = new CookieManager();
            cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
            CookieHandler.setDefault(cm);
        }
        // else {
        // CookieStoreHolder.initInMemoryCookieStore();
        // }

    }
 
开发者ID:clstoulouse,项目名称:motu,代码行数:17,代码来源:CookieStoreHolder.java

示例10: buildOkHttpClient

import java.net.CookieManager; //导入方法依赖的package包/类
static OkHttpClient buildOkHttpClient() {
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);

    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    return new OkHttpClient.Builder()
            .addInterceptor(new HasuraTokenInterceptor())
            .addInterceptor(logging)
            .cookieJar(new JavaNetCookieJar(cookieManager))
            .build();
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:14,代码来源:Hasura.java

示例11: AuthService

import java.net.CookieManager; //导入方法依赖的package包/类
public AuthService(String authUrl) {
    this.authUrl = authUrl;
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    this.httpClient
            = new OkHttpClient.Builder()
            .cookieJar(new JavaNetCookieJar(cookieManager))
            .build();
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:10,代码来源:AuthService.java

示例12: startCookieSession

import java.net.CookieManager; //导入方法依赖的package包/类
private static void startCookieSession(){

		cookieManager=new CookieManager();
		cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
		cookieManager.getCookieStore().removeAll();

		if(android) {
			CookieHandler.setDefault(cookieManager);
		}

	}
 
开发者ID:davovoid,项目名称:faitic-checker,代码行数:12,代码来源:Faitic.java

示例13: setCookieHandler

import java.net.CookieManager; //导入方法依赖的package包/类
private static void setCookieHandler()
{
    synchronized (LOCK)
    {
        CookieManager cookieManager = new CookieManager();
        cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(cookieManager);
        mOkHttpClient.setCookieHandler(cookieManager);
    }
}
 
开发者ID:rohanoid5,项目名称:CineBuff,代码行数:11,代码来源:HttpClientFactory.java

示例14: createOkhttp

import java.net.CookieManager; //导入方法依赖的package包/类
@NonNull
public OkHttpClient createOkhttp() {
    if (null == okHttpClient) {
        File httpCacheDirectory = new File(getCacheDir(getContext()), "SmartHome_Cache");
        CookieManager cookieManager = new CookieManager();
        cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(cookieManager);
        okHttpClient = new OkHttpClient.Builder().build();
    }

    return okHttpClient;
}
 
开发者ID:EthanCo,项目名称:AndroidTesting,代码行数:13,代码来源:RetrofitFactory.java

示例15: initInMemoryCookieStore

import java.net.CookieManager; //导入方法依赖的package包/类
public static CookieStore initInMemoryCookieStore() {
    CookieStore cookieStore = CookieStoreHolder.getCookieStore();
    if (cookieStore == null) {
        CookieManager cm = new CookieManager();
        cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieStoreHolder.setCookieStore(cm.getCookieStore());
    } else {
        cookieStore.removeAll();
    }

    return cookieStore;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:13,代码来源:CookieStoreHolder.java


注:本文中的java.net.CookieManager.setCookiePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。