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


Java CookieSpecs類代碼示例

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


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

示例1: OAuthHttpClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public OAuthHttpClient(int maxConnection, int connectTimeout, int socketTimeout) {
    PoolingHttpClientConnectionManager connectionManager =
            new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create()
                    .register("http", PlainConnectionSocketFactory.getSocketFactory())
                    .register("https", SSLConnectionSocketFactory.getSocketFactory())
                    .build());
    // set max connection
    connectionManager.setMaxTotal(maxConnection);

    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(connectTimeout)
            .setSocketTimeout(socketTimeout)
            .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
            .build();

    httpClient = HttpClientBuilder.create()
            .setConnectionManager(connectionManager)
            .setDefaultRequestConfig(requestConfig)
            .setRetryHandler(new DefaultHttpRequestRetryHandler(3, true))
            .build();
}
 
開發者ID:xiaomi-passport,項目名稱:oauth-java-sdk,代碼行數:22,代碼來源:OAuthHttpClient.java

示例2: buildHttpClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
/**
 * Builds a custom Http client with custom DNS resolution, disabling persistent cookie stores and with custom
 * timeout values.
 *
 * @return An http client to be used to execute test requests to nginx.
 */
static CloseableHttpClient buildHttpClient() {
    return HttpClients.custom()
            .setConnectionManager(buildConnectionManager())
            .setDefaultRequestConfig(RequestConfig.custom()
                    // Waiting for a connection from connection manager
                    .setConnectionRequestTimeout(100)
                    // Waiting for connection to establish
                    .setConnectTimeout(100)
                    .setExpectContinueEnabled(false)
                    // Waiting for data
                    .setSocketTimeout(200)
                    // Do not allow cookies to be stored between calls.
                    .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
                    .build())
            .setRetryHandler(buildRetryHandler())
            .disableRedirectHandling().build();
}
 
開發者ID:Kroger-Technology,項目名稱:Snow-Globe,代碼行數:24,代碼來源:CallUtility.java

示例3: generateClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
@Override
public CloseableHttpAsyncClient generateClient ()
{
   CredentialsProvider credsProvider = new BasicCredentialsProvider();
   credsProvider.setCredentials(new AuthScope (AuthScope.ANY),
           new UsernamePasswordCredentials(serviceUser, servicePass));
   RequestConfig rqconf = RequestConfig.custom()
         .setCookieSpec(CookieSpecs.DEFAULT)
         .setSocketTimeout(Timeouts.SOCKET_TIMEOUT)
         .setConnectTimeout(Timeouts.CONNECTION_TIMEOUT)
         .setConnectionRequestTimeout(Timeouts.CONNECTION_REQUEST_TIMEOUT)
         .build();
   CloseableHttpAsyncClient res = HttpAsyncClients.custom ()
         .setDefaultCredentialsProvider (credsProvider)
         .setDefaultRequestConfig(rqconf)
         .build ();
   res.start ();
   return res;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:20,代碼來源:ODataProductSynchronizer.java

示例4: generateClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
@Override
public CloseableHttpAsyncClient generateClient ()
{
   CredentialsProvider credsProvider = new BasicCredentialsProvider();
   credsProvider.setCredentials(new AuthScope (AuthScope.ANY),
            new UsernamePasswordCredentials(username, password));
   RequestConfig rqconf = RequestConfig.custom()
         .setCookieSpec(CookieSpecs.DEFAULT)
         .setSocketTimeout(Timeouts.SOCKET_TIMEOUT)
         .setConnectTimeout(Timeouts.CONNECTION_TIMEOUT)
         .setConnectionRequestTimeout(Timeouts.CONNECTION_REQUEST_TIMEOUT)
         .build();
   CloseableHttpAsyncClient res = HttpAsyncClients.custom ()
         .setDefaultCredentialsProvider (credsProvider)
         .setDefaultRequestConfig(rqconf)
         .build ();
   res.start ();
   return res;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:20,代碼來源:ODataClient.java

示例5: apiRequest

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
private HttpRequestBase apiRequest(String apiMethod, List<NameValuePair> params) {
  HttpPost post = new HttpPost(getRestApiUrl(apiMethod));
  post.setConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES).build());

  List<NameValuePair> formFields = new ArrayList<>();
  formFields.add(new BasicNameValuePair("api.token", myPassword));
  formFields.addAll(params);

  try {
    post.setEntity(new UrlEncodedFormEntity(formFields, "UTF-8"));
  }
  catch (UnsupportedEncodingException ignored) {
    // cannot happen
  }
  return post;
}
 
開發者ID:mmm444,項目名稱:ijphab,代碼行數:17,代碼來源:PhabricatorRepository.java

示例6: send

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
@Override
protected CloseableHttpResponse send(CloseableHttpClient httpClient, String base) throws Exception {
    List<NameValuePair> formParams = new ArrayList<>();
    for (String key : params.keySet()) {
        String value = params.get(key);
        formParams.add(new BasicNameValuePair(key, value));
    }
    HttpPost request = new HttpPost(base);

    RequestConfig localConfig = RequestConfig.custom()
            .setCookieSpec(CookieSpecs.STANDARD)
            .build();
    request.setConfig(localConfig);
    request.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8"));
    request.setHeader("Content-Type", "application/x-www-form-urlencoded");        //內容為post
    return httpClient.execute(request);
}
 
開發者ID:a483210,項目名稱:GoogleTranslation,代碼行數:18,代碼來源:HttpPostParams.java

示例7: HttpUtils

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
private HttpUtils(HttpRequestBase request) {
	this.request = request;

	this.clientBuilder = HttpClientBuilder.create();
	this.isHttps = request.getURI().getScheme().equalsIgnoreCase("https");
	this.config = RequestConfig.custom().setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY);
	this.cookieStore = new BasicCookieStore();

	if (request instanceof HttpPost) {
		this.type = 1;
		this.builder = EntityBuilder.create().setParameters(new ArrayList<NameValuePair>());

	} else if (request instanceof HttpGet) {
		this.type = 2;
		this.uriBuilder = new URIBuilder();

	} else if (request instanceof HttpPut) {
		this.type = 3;
		this.builder = EntityBuilder.create().setParameters(new ArrayList<NameValuePair>());

	} else if (request instanceof HttpDelete) {
		this.type = 4;
		this.uriBuilder = new URIBuilder();
	}
}
 
開發者ID:swxiao,項目名稱:bubble2,代碼行數:26,代碼來源:HttpUtils.java

示例8: toHttpUriRequest

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public HttpUriRequest toHttpUriRequest() {
    LOGGER.debug("in createRequestBuilder");
    RequestBuilder requestBuilder = createRequestBuilder();
    int timeout = httpServiceInfo.getTimeout();
    RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
            .setConnectionRequestTimeout(timeout)
            .setSocketTimeout(timeout)
            .setConnectTimeout(timeout)
            .setCookieSpec(CookieSpecs.IGNORE_COOKIES);

    requestBuilder.setConfig(requestConfigBuilder.build());
    if (StringUtils.isNoneEmpty(httpServiceInfo.getContentType())) {
        requestBuilder.addHeader("Content-Type", httpServiceInfo.getContentType());
    } else {
        requestBuilder.addHeader("Content-Type", httpServletRequest.getContentType());
    }
    return requestBuilder.build();
}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:19,代碼來源:HttpServiceRequest.java

示例9: post0

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
private static HttpUriRequest post0(String url, Map<String, String> params) {
    RequestBuilder requestBuilder = RequestBuilder.post().setCharset(CHARSET).setUri(url);
    RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
            .setConnectionRequestTimeout(TIMEOUT)
            .setSocketTimeout(TIMEOUT)
            .setConnectTimeout(TIMEOUT).setCookieSpec(CookieSpecs.IGNORE_COOKIES);
    requestBuilder.setConfig(requestConfigBuilder.build());
    if (params != null && params.size() > 0) {
        List<NameValuePair> nvList = new ArrayList<>();
        for (Map.Entry<String, String> param : params.entrySet()) {
            Object value = param.getValue();
            if (value == null) {
                continue;
            }
            nvList.add(new BasicNameValuePair(param.getKey(), value.toString()));
        }
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nvList, CHARSET);
        requestBuilder.setEntity(formEntity);
    }
    requestBuilder.addHeader("Connection", "Keep-Alive");
    return requestBuilder.build();

}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:24,代碼來源:IpClient.java

示例10: HttpTransportClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public HttpTransportClient(int retryAttemptsNetworkErrorCount, int retryAttemptsInvalidStatusCount) {
    this.retryAttemptsNetworkErrorCount = retryAttemptsNetworkErrorCount;
    this.retryAttemptsInvalidStatusCount = retryAttemptsInvalidStatusCount;

    CookieStore cookieStore = new BasicCookieStore();
    RequestConfig requestConfig = RequestConfig.custom()
            .setSocketTimeout(SOCKET_TIMEOUT_MS)
            .setConnectTimeout(CONNECTION_TIMEOUT_MS)
            .setConnectionRequestTimeout(CONNECTION_TIMEOUT_MS)
            .setCookieSpec(CookieSpecs.STANDARD)
            .build();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();

    connectionManager.setMaxTotal(MAX_SIMULTANEOUS_CONNECTIONS);
    connectionManager.setDefaultMaxPerRoute(MAX_SIMULTANEOUS_CONNECTIONS);

    httpClient = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .setDefaultRequestConfig(requestConfig)
            .setDefaultCookieStore(cookieStore)
            .setUserAgent(USER_AGENT)
            .build();
}
 
開發者ID:VKCOM,項目名稱:vk-java-sdk,代碼行數:25,代碼來源:HttpTransportClient.java

示例11: NestSession

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public NestSession(String username, String password) throws LoginException {
	super();
	theLine = null;
	theBody = null;
	response = null;
	theUsername = new String(username);
	thePassword = new String(password);
	log.info("Starting Nest login...");
	retry = 0;
       // Trust own CA and all self-signed certs
       sslcontext = SSLContexts.createDefault();
       // Allow TLSv1 protocol only
       sslsf = new SSLConnectionSocketFactory(
               sslcontext,
               new String[] { "TLSv1" },
               null,
               SSLConnectionSocketFactory.getDefaultHostnameVerifier());
       globalConfig = RequestConfig.custom()
               .setCookieSpec(CookieSpecs.STANDARD)
               .build();
       
       _login();
}
 
開發者ID:bwssytems,項目名稱:nest-controller,代碼行數:24,代碼來源:NestSession.java

示例12: send

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
@Override
protected CloseableHttpResponse send(CloseableHttpClient httpClient, String base) throws Exception {
	List<NameValuePair> formparams = new ArrayList<NameValuePair>();
	for (String key : params.keySet()) {
		String value = params.get(key);
		formparams.add(new BasicNameValuePair(key, value));
	}
	HttpPost request = new HttpPost(base);

       RequestConfig localConfig = RequestConfig.custom()
               .setCookieSpec(CookieSpecs.STANDARD)
               .build();
       request.setConfig(localConfig); 
	request.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
	request.setHeader("Content-Type", "application/x-www-form-urlencoded");		//內容為post
	return httpClient.execute(request);
}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:18,代碼來源:HttpPostParams.java

示例13: createHttpClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public static CloseableHttpClient createHttpClient(final int maxRedirects) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    s_logger.info("Creating new HTTP connection pool and client");
    final Registry<ConnectionSocketFactory> socketFactoryRegistry = createSocketFactoryConfigration();
    final BasicCookieStore cookieStore = new BasicCookieStore();
    final PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
    connManager.setDefaultMaxPerRoute(MAX_ALLOCATED_CONNECTIONS_PER_ROUTE);
    connManager.setMaxTotal(MAX_ALLOCATED_CONNECTIONS);
    final RequestConfig requestConfig = RequestConfig.custom()
                                                     .setCookieSpec(CookieSpecs.DEFAULT)
                                                     .setMaxRedirects(maxRedirects)
                                                     .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT)
                                                     .setConnectionRequestTimeout(DEFAULT_CONNECTION_REQUEST_TIMEOUT)
                                                     .setConnectTimeout(DEFAULT_CONNECT_TIMEOUT)
                                                     .build();
    return HttpClientBuilder.create()
                            .setConnectionManager(connManager)
                            .setRedirectStrategy(new LaxRedirectStrategy())
                            .setDefaultRequestConfig(requestConfig)
                            .setDefaultCookieStore(cookieStore)
                            .setRetryHandler(new StandardHttpRequestRetryHandler())
                            .build();
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:23,代碼來源:HttpClientHelper.java

示例14: createHttpClient

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
protected CloseableHttpClient createHttpClient(Map<String, Object> parameters)
{
	HttpClientBuilder clientBuilder = HttpClients.custom();
	
	// single connection
	BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager();
	clientBuilder.setConnectionManager(connManager);
	
	// ignore cookies for now
	RequestConfig requestConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
	clientBuilder.setDefaultRequestConfig(requestConfig);
	
	setAuthentication(parameters, clientBuilder);
	
	CloseableHttpClient client = clientBuilder.build();
	return client;
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:18,代碼來源:HttpDataService.java

示例15: ProcessConnection

import org.apache.http.client.config.CookieSpecs; //導入依賴的package包/類
public ProcessConnection(ProcessDirector director, PhantomJSProcess process)
{
	this.process = process;
	
	HttpClientBuilder clientBuilder = HttpClients.custom();
	
	// single connection
	BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager();
	clientBuilder.setConnectionManager(connManager);
	
	RequestConfig requestConfig = RequestConfig.custom()
			// ignore cookies for now
			.setCookieSpec(CookieSpecs.IGNORE_COOKIES)
			.setSocketTimeout(director.getRequestTimeout()).build();
	clientBuilder.setDefaultRequestConfig(requestConfig);
	
	this.httpClient = clientBuilder.build();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:19,代碼來源:ProcessConnection.java


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