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


Java CookiePolicy類代碼示例

本文整理匯總了Java中org.apache.http.client.params.CookiePolicy的典型用法代碼示例。如果您正苦於以下問題:Java CookiePolicy類的具體用法?Java CookiePolicy怎麽用?Java CookiePolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CookiePolicy類屬於org.apache.http.client.params包,在下文中一共展示了CookiePolicy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCookieSpecRegistry

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
protected CookieSpecRegistry createCookieSpecRegistry() {
    CookieSpecRegistry registry = new CookieSpecRegistry();
    registry.register(
            CookiePolicy.BEST_MATCH,
            new BestMatchSpecFactory());
    registry.register(
            CookiePolicy.BROWSER_COMPATIBILITY,
            new BrowserCompatSpecFactory());
    registry.register(
            CookiePolicy.NETSCAPE,
            new NetscapeDraftSpecFactory());
    registry.register(
            CookiePolicy.RFC_2109,
            new RFC2109SpecFactory());
    registry.register(
            CookiePolicy.RFC_2965,
            new RFC2965SpecFactory());
    registry.register(
            CookiePolicy.IGNORE_COOKIES,
            new IgnoreSpecFactory());
    return registry;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:AbstractHttpClient.java

示例2: createCookieSpecRegistry

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
protected CookieSpecRegistry createCookieSpecRegistry() {
    final CookieSpecRegistry registry = new CookieSpecRegistry();
    registry.register(
            CookieSpecs.DEFAULT,
            new BestMatchSpecFactory());
    registry.register(
            CookiePolicy.BEST_MATCH,
            new BestMatchSpecFactory());
    registry.register(
            CookiePolicy.BROWSER_COMPATIBILITY,
            new BrowserCompatSpecFactory());
    registry.register(
            CookiePolicy.NETSCAPE,
            new NetscapeDraftSpecFactory());
    registry.register(
            CookiePolicy.RFC_2109,
            new RFC2109SpecFactory());
    registry.register(
            CookiePolicy.RFC_2965,
            new RFC2965SpecFactory());
    registry.register(
            CookiePolicy.IGNORE_COOKIES,
            new IgnoreSpecFactory());
    return registry;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:26,代碼來源:AbstractHttpClient.java

示例3: init

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@Override
public void init() throws ServletException {
  String doLogStr = getConfigParam(P_LOG);
  if (doLogStr != null) {
    this.doLog = Boolean.parseBoolean(doLogStr);
  }

  String doForwardIPString = getConfigParam(P_FORWARDEDFOR);
  if (doForwardIPString != null) {
    this.doForwardIP = Boolean.parseBoolean(doForwardIPString);
  }

  initTarget();//sets target*

  HttpParams hcParams = new BasicHttpParams();
  hcParams.setParameter(ClientPNames.COOKIE_POLICY,
      CookiePolicy.IGNORE_COOKIES);
  readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class);
  proxyClient = createHttpClient(hcParams);
}
 
開發者ID:hopshadoop,項目名稱:hopsworks,代碼行數:21,代碼來源:ProxyServlet.java

示例4: init

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@Override
public void init() throws ServletException {
    String doLogStr = getConfigParam(P_LOG);
    if (doLogStr != null) {
        this.doLog = Boolean.parseBoolean(doLogStr);
    }

    String doForwardIPString = getConfigParam(P_FORWARDEDFOR);
    if (doForwardIPString != null) {
        this.doForwardIP = Boolean.parseBoolean(doForwardIPString);
    }

    initTarget();// sets target*

    HttpParams hcParams = new BasicHttpParams();
    hcParams.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES);
    readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class);
    proxyClient = createHttpClient(hcParams);
}
 
開發者ID:sercxtyf,項目名稱:onboard,代碼行數:20,代碼來源:ApiProxyServlet.java

示例5: getDefaultHttpClient

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
/** 
 * 獲取DefaultHttpClient對象 
 *  
 * @param charset 
 *            字符編碼 
 * @return DefaultHttpClient對象 
 */  
private static DefaultHttpClient getDefaultHttpClient(final String charset) {  
    DefaultHttpClient httpclient = new DefaultHttpClient();  
    // 模擬瀏覽器,解決一些服務器程序隻允許瀏覽器訪問的問題  
    httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,  
            USER_AGENT);  
    httpclient.getParams().setParameter(  
            CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);  
    httpclient.getParams().setParameter(  
            CoreProtocolPNames.HTTP_CONTENT_CHARSET,  
            charset == null ? CHARSET_ENCODING : charset);  
      
    // 瀏覽器兼容性  
    httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY,  
            CookiePolicy.BROWSER_COMPATIBILITY);  
    // 定義重試策略  
    httpclient.setHttpRequestRetryHandler(requestRetryHandler);  
      
    return httpclient;  
}
 
開發者ID:hoozheng,項目名稱:AndroidRobot,代碼行數:27,代碼來源:HttpClientUtil.java

示例6: createCookieSpecRegistry

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@Override
protected CookieSpecRegistry createCookieSpecRegistry() {
    CookieSpecRegistry registry = new CookieSpecRegistry();
    registry.register(
            CookiePolicy.BEST_MATCH, 
            new BestMatchSpecFactory());
    registry.register(
            CookiePolicy.BROWSER_COMPATIBILITY, 
            new BrowserCompatSpecFactory());
    registry.register(
            CookiePolicy.NETSCAPE, 
            new NetscapeDraftSpecFactory());
    registry.register(
            CookiePolicy.RFC_2109, 
            new RFC2109SpecFactory());
    registry.register(
            CookiePolicy.RFC_2965, 
            new RFC2965SpecFactory());
    return registry;
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:21,代碼來源:DefaultHttpClient.java

示例7: testCookiePolicy

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Test
public void testCookiePolicy() {
	SpringClientFactory factory = new SpringClientFactory();
	AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
	addEnvironment(parent, "ribbon.restclient.enabled=true");
	parent.register(RibbonAutoConfiguration.class, ArchaiusAutoConfiguration.class);
	parent.refresh();
	factory.setApplicationContext(parent);
	RestClient client = factory.getClient("foo", RestClient.class);
	ApacheHttpClient4 jerseyClient = (ApacheHttpClient4) client.getJerseyClient();
	assertEquals(CookiePolicy.IGNORE_COOKIES, jerseyClient.getClientHandler()
			.getHttpClient().getParams().getParameter(ClientPNames.COOKIE_POLICY));
	parent.close();
	factory.destroy();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:17,代碼來源:SpringClientFactoryTests.java

示例8: getClient

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
public synchronized HttpClient getClient() {
    if (m_client == null) {
        m_client = new DefaultHttpClient();

        HttpParams clientParams = m_client.getParams();
        clientParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, m_timeout);
        clientParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, m_timeout);
        clientParams.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
        m_client.setParams(clientParams);

        m_client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(m_retries, false));

    }

    return m_client;
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:17,代碼來源:RequestTracker.java

示例9: buildParams

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
private static HttpParams buildParams(final HttpCollectionSet collectionSet) {
    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, computeVersion(collectionSet.getUriDef()));
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.parseInt(ParameterMap.getKeyedString(collectionSet.getParameters(), "timeout", DEFAULT_SO_TIMEOUT)));
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.parseInt(ParameterMap.getKeyedString(collectionSet.getParameters(), "timeout", DEFAULT_SO_TIMEOUT)));
    params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);

    //review the httpclient code, looks like virtual host is checked for null
    //and if true, sets Host to the connection's host property
    String virtualHost = collectionSet.getUriDef().getUrl().getVirtualHost();
    if (virtualHost != null) {
        params.setParameter(
                            ClientPNames.VIRTUAL_HOST, 
                            new HttpHost(virtualHost, collectionSet.getPort())
        );
    }

    return params;
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:20,代碼來源:HttpCollector.java

示例10: ConnectionHelper

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
private ConnectionHelper() {
	HttpParams httpParams = new BasicHttpParams();
	ConnManagerParams.setMaxTotalConnections(httpParams,
			MAX_TOTAL_CONNECTIONS);
	ConnPerRouteBean connPerRoute = new ConnPerRouteBean(
			MAX_CONNECTIONS_PER_HOST);
	ConnManagerParams.setMaxConnectionsPerRoute(httpParams, connPerRoute);

	HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
	HttpProtocolParams.setUseExpectContinue(httpParams, false);
	SchemeRegistry reg = new SchemeRegistry();
	reg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
			80));
	reg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(),
			443));
	ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(
			httpParams, reg);
	HttpConnectionParams.setConnectionTimeout(httpParams, CON_TIME_OUT_MS);
	HttpConnectionParams.setSoTimeout(httpParams, SO_TIME_OUT_MS);

	HttpClientParams.setCookiePolicy(httpParams,
			CookiePolicy.BROWSER_COMPATIBILITY);
	httpClient = new DefaultHttpClient(connectionManager, httpParams);
}
 
開發者ID:shenkaige,項目名稱:AndroidHttpTools,代碼行數:25,代碼來源:ConnectionHelper.java

示例11: the_approval_will_be_remembered

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@Test
@DatabaseSetup("/database_seed.xml")
public void the_approval_will_be_remembered() throws IOException {
    givenValidAuthCode("marissa", "koala", "internal");
    givenAuthCode();
    givenAccessTokenUsingAuthCode();

    {
        HttpGet httpGet = new HttpGet(loginUri);
        httpGet.getParams().setParameter(ClientPNames.COOKIE_POLICY,
                CookiePolicy.NETSCAPE);
        httpGet.getParams().setBooleanParameter("http.protocol.handle-redirects", false);
        authCodeResponse = httpClient.execute(httpGet);
        httpGet.releaseConnection();
    }
    givenAuthCode();
    givenAccessTokenUsingAuthCode();

    assertTrue(accessToken != null);
    assertNotNull(accessToken.getRefreshToken());
}
 
開發者ID:osiam,項目名稱:connector4java-integration-tests,代碼行數:22,代碼來源:LoginOAuth2IT.java

示例12: the_approval_will_not_be_remembered_if_validity_is_zero

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
@Test
@DatabaseSetup("/database_seeds/LoginOAuth2IT/database_seed_zero_validity.xml")
public void the_approval_will_not_be_remembered_if_validity_is_zero() throws IOException {
    givenValidAuthCode("marissa", "koala", "internal");
    givenAuthCode();
    givenAccessTokenUsingAuthCode();

    HttpGet httpGet = new HttpGet(loginUri);
    httpGet.getParams().setParameter(ClientPNames.COOKIE_POLICY,
            CookiePolicy.NETSCAPE);
    httpGet.getParams().setBooleanParameter("http.protocol.handle-redirects", false);
    authCodeResponse = httpClient.execute(httpGet);
    String response = IOUtils.toString(authCodeResponse.getEntity().getContent());
    httpGet.releaseConnection();

    assertThat(response, containsString("<title>Access confirmation</title>"));
}
 
開發者ID:osiam,項目名稱:connector4java-integration-tests,代碼行數:18,代碼來源:LoginOAuth2IT.java

示例13: HttpStoreClientFactory

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
public HttpStoreClientFactory(ClientConfig config) {
    super(config);
    ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                      config.getConnectionTimeout(TimeUnit.MILLISECONDS),
                                                                      TimeUnit.MILLISECONDS);
    mgr.setMaxTotal(config.getMaxTotalConnections());
    mgr.setDefaultMaxPerRoute(config.getMaxConnectionsPerNode());

    this.httpClient = new DefaultHttpClient(mgr);
    HttpParams clientParams = this.httpClient.getParams();

    HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
    HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);

    HttpConnectionParams.setConnectionTimeout(clientParams,
                                              config.getConnectionTimeout(TimeUnit.MILLISECONDS));
    HttpConnectionParams.setSoTimeout(clientParams,
                                      config.getSocketTimeout(TimeUnit.MILLISECONDS));
    HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

    this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
    HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

    this.reroute = config.getRoutingTier().equals(RoutingTier.SERVER);
    this.requestFormatFactory = new RequestFormatFactory();
}
 
開發者ID:we7,項目名稱:voldemort,代碼行數:27,代碼來源:HttpStoreClientFactory.java

示例14: createClient

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
private DefaultHttpClient createClient(boolean https)
{
	final DefaultHttpClient client = (https ? new DefaultHttpClient(conMan) : new DefaultHttpClient());
	// Allows a slightly lenient cookie acceptance
	client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
	// Allows follow of redirects on POST
	client.setRedirectStrategy(new LaxRedirectStrategy());
	return client;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:10,代碼來源:HttpServiceImpl.java

示例15: setup

import org.apache.http.client.params.CookiePolicy; //導入依賴的package包/類
/**
 * Setup some variables
 */
public void setup() {
    log.info("Setup...");
    
    if (StringUtils.isEmpty(this.username)) {
        throw new IllegalArgumentException("Username is mandatory.");
    }
    
    if (StringUtils.isEmpty(this.password)) {
        throw new IllegalArgumentException("Password is mandatory.");
    }
    
    this.deviceId = InstagramHashUtil.generateDeviceId(this.username, this.password);
    
    if (StringUtils.isEmpty(this.uuid)) {
        this.uuid = InstagramGenericUtil.generateUuid(true);
    }
    
    if (this.cookieStore == null) {
        this.cookieStore = new BasicCookieStore();
    }
    
    log.info("Device ID is: " + this.deviceId + ", random id: " + this.uuid);
    
    this.client = new DefaultHttpClient();
    this.client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
    this.client.setCookieStore(this.cookieStore);

}
 
開發者ID:brunocvcunha,項目名稱:instagram4j,代碼行數:32,代碼來源:Instagram4j.java


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