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


Java CookieSpecProvider类代码示例

本文整理汇总了Java中org.apache.http.cookie.CookieSpecProvider的典型用法代码示例。如果您正苦于以下问题:Java CookieSpecProvider类的具体用法?Java CookieSpecProvider怎么用?Java CookieSpecProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: afterPropertiesSet

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider> create().register("easy", new CookieSpecProvider() {
		public CookieSpec create(HttpContext context) {
			return new DefaultCookieSpec() {
				@Override
				public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
				}
			};
		}
	}).build();

	requestConfig = RequestConfig.custom().setCookieSpec("easy")
			.setConnectionRequestTimeout(propertyConfigurer.getIntValue("connection.request.timeout"))
			.setSocketTimeout(propertyConfigurer.getIntValue("socket_timeout"))
			.setConnectTimeout(propertyConfigurer.getIntValue("connection_timeout")).build();
}
 
开发者ID:JK-River,项目名称:RobotServer,代码行数:18,代码来源:HttpService.java

示例2: InternalHttpClient

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public InternalHttpClient(
        final ClientExecChain execChain,
        final HttpClientConnectionManager connManager,
        final HttpRoutePlanner routePlanner,
        final Lookup<CookieSpecProvider> cookieSpecRegistry,
        final Lookup<AuthSchemeProvider> authSchemeRegistry,
        final CookieStore cookieStore,
        final CredentialsProvider credentialsProvider,
        final RequestConfig defaultConfig,
        final List<Closeable> closeables) {
    super();
    Args.notNull(execChain, "HTTP client exec chain");
    Args.notNull(connManager, "HTTP connection manager");
    Args.notNull(routePlanner, "HTTP route planner");
    this.execChain = execChain;
    this.connManager = connManager;
    this.routePlanner = routePlanner;
    this.cookieSpecRegistry = cookieSpecRegistry;
    this.authSchemeRegistry = authSchemeRegistry;
    this.cookieStore = cookieStore;
    this.credentialsProvider = credentialsProvider;
    this.defaultConfig = defaultConfig;
    this.closeables = closeables;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:25,代码来源:InternalHttpClient.java

示例3: createDefaultBuilder

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
/**
 * Creates a builder containing the default registry entries, using the provided public suffix matcher.
 */
public static RegistryBuilder<CookieSpecProvider> createDefaultBuilder(final PublicSuffixMatcher publicSuffixMatcher) {
    final CookieSpecProvider defaultProvider = new DefaultCookieSpecProvider(publicSuffixMatcher);
    final CookieSpecProvider laxStandardProvider = new RFC6265CookieSpecProvider(
            RFC6265CookieSpecProvider.CompatibilityLevel.RELAXED, publicSuffixMatcher);
    final CookieSpecProvider strictStandardProvider = new RFC6265CookieSpecProvider(
            RFC6265CookieSpecProvider.CompatibilityLevel.STRICT, publicSuffixMatcher);
    return RegistryBuilder.<CookieSpecProvider>create()
            .register(CookieSpecs.DEFAULT, defaultProvider)
            .register("best-match", defaultProvider)
            .register("compatibility", defaultProvider)
            .register(CookieSpecs.STANDARD, laxStandardProvider)
            .register(CookieSpecs.STANDARD_STRICT, strictStandardProvider)
            .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
            .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:19,代码来源:CookieSpecRegistries.java

示例4: setUp

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
@Before
public void setUp() {
    this.target = new HttpHost("localhost.local", 80);
    this.cookieStore = new BasicCookieStore();
    final BasicClientCookie2 cookie1 = new BasicClientCookie2("name1", "value1");
    cookie1.setVersion(1);
    cookie1.setDomain("localhost.local");
    cookie1.setPath("/");
    this.cookieStore.addCookie(cookie1);
    final BasicClientCookie2 cookie2 = new BasicClientCookie2("name2", "value2");
    cookie2.setVersion(1);
    cookie2.setDomain("localhost.local");
    cookie2.setPath("/");
    this.cookieStore.addCookie(cookie2);

    this.cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
        .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
        .register(CookieSpecs.STANDARD, new RFC2965SpecProvider())
        .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
        .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider())
        .build();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestRequestAddCookies.java

示例5: testExecuteLocalContext

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecuteLocalContext() throws Exception {
    final HttpGet httpget = new HttpGet("http://somehost/stuff");
    final HttpClientContext context = HttpClientContext.create();

    final Lookup<CookieSpecProvider> localCookieSpecRegistry = Mockito.mock(Lookup.class);
    final Lookup<AuthSchemeProvider> localAuthSchemeRegistry = Mockito.mock(Lookup.class);
    final CookieStore localCookieStore = Mockito.mock(CookieStore.class);
    final CredentialsProvider localCredentialsProvider = Mockito.mock(CredentialsProvider.class);
    final RequestConfig localConfig = RequestConfig.custom().build();

    context.setCookieSpecRegistry(localCookieSpecRegistry);
    context.setAuthSchemeRegistry(localAuthSchemeRegistry);
    context.setCookieStore(localCookieStore);
    context.setCredentialsProvider(localCredentialsProvider);
    context.setRequestConfig(localConfig);

    client.execute(httpget, context);

    Assert.assertSame(localCookieSpecRegistry, context.getCookieSpecRegistry());
    Assert.assertSame(localAuthSchemeRegistry, context.getAuthSchemeRegistry());
    Assert.assertSame(localCookieStore, context.getCookieStore());
    Assert.assertSame(localCredentialsProvider, context.getCredentialsProvider());
    Assert.assertSame(localConfig, context.getRequestConfig());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:27,代码来源:TestInternalHttpClient.java

示例6: createCookieSpecRegistry

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
protected Lookup<CookieSpecProvider> createCookieSpecRegistry() {
    CookieSpecProvider cookieSpecProvider = createCookieSpecProvider();
    Registry<CookieSpecProvider> cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
            .register(NoopCookieSpecProvider.NAME, cookieSpecProvider)
            .build();
    return cookieSpecRegistry;
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:8,代码来源:HttpClientFactory.java

示例7: setCookieStore

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public void setCookieStore(String path, String md5) throws ClassNotFoundException, IOException {
	context = HttpClientContext.create();
	Registry<CookieSpecProvider> registry = RegistryBuilder  
               .<CookieSpecProvider> create()  
               .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider()).build();
	context.setCookieSpecRegistry(registry);
	
	context.setCookieStore(loadCookies(path, md5));
}
 
开发者ID:Saisimon,项目名称:tip,代码行数:10,代码来源:HttpsClient.java

示例8: createExecutor

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public static Executor createExecutor(CookieStore cookieStore) {
    @SuppressWarnings("deprecation") final Registry<CookieSpecProvider> cookieSpecRegistry =
            RegistryBuilder.<CookieSpecProvider>create().register(CookieSpecs.DEFAULT, new BrowserCompatSpecFactory()).build();
    final CloseableHttpClient client = HttpClients.custom()
            .setDefaultCookieSpecRegistry(cookieSpecRegistry)
            .setDefaultCookieStore(cookieStore)
            .build();
    return Executor.newInstance(client);
}
 
开发者ID:Roboroxx,项目名称:itunesconnect-api,代码行数:10,代码来源:Utils.java

示例9: getHttpClientContext

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public static HttpClientContext getHttpClientContext() {
    HttpClientContext context = null;
    context = HttpClientContext.create();
    Registry<CookieSpecProvider> registry = RegistryBuilder
            .<CookieSpecProvider>create()
            .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
            .register(CookieSpecs.BROWSER_COMPATIBILITY,
                    new BrowserCompatSpecFactory()).build();
    context.setCookieSpecRegistry(registry);
    return context;
}
 
开发者ID:MatrixSeven,项目名称:ZhihuSpider,代码行数:12,代码来源:HttpUtil.java

示例10: createCookieSpecProvider

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
protected CookieSpecProvider createCookieSpecProvider() {
    return new NoopCookieSpecProvider();
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:4,代码来源:HttpClientFactory.java

示例11: registry

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public static Registry<CookieSpecProvider> registry() {
    CookieSpecProvider specProvider = (HttpContext hc) -> new LenientCookieSpec();
    return RegistryBuilder.<CookieSpecProvider>create()
            .register(KARATE, specProvider).build();
}
 
开发者ID:intuit,项目名称:karate,代码行数:6,代码来源:LenientCookieSpec.java

示例12: getCookieSpecRegistry

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public Lookup<CookieSpecProvider> getCookieSpecRegistry() {
    return getLookup(COOKIESPEC_REGISTRY, CookieSpecProvider.class);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:4,代码来源:HttpClientContext.java

示例13: setCookieSpecRegistry

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public void setCookieSpecRegistry(final Lookup<CookieSpecProvider> lookup) {
    setAttribute(COOKIESPEC_REGISTRY, lookup);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:4,代码来源:HttpClientContext.java

示例14: setDefaultCookieSpecRegistry

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
/**
 * Assigns default {@link org.apache.http.cookie.CookieSpec} registry which will
 * be used for request execution if not explicitly set in the client execution
 * context.
 */
public final HttpClientBuilder setDefaultCookieSpecRegistry(
        final Lookup<CookieSpecProvider> cookieSpecRegistry) {
    this.cookieSpecRegistry = cookieSpecRegistry;
    return this;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:11,代码来源:HttpClientBuilder.java

示例15: main

import org.apache.http.cookie.CookieSpecProvider; //导入依赖的package包/类
public final static void main(String[] args) throws Exception {

        // Use PublicSuffixMatcherLoader to load public suffix list from a file,
        // resource or from an arbitrary URL
        PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(
                new URL("https://publicsuffix.org/list/effective_tld_names.dat"));

        // Please use the publicsuffix.org URL to download the list no more than once per day !!!
        // Please consider making a local copy !!!

        DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher);

        RFC6265CookieSpecProvider cookieSpecProvider = new RFC6265CookieSpecProvider(publicSuffixMatcher);
        Lookup<CookieSpecProvider> cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
                .register(CookieSpecs.DEFAULT, cookieSpecProvider)
                .register(CookieSpecs.STANDARD, cookieSpecProvider)
                .register(CookieSpecs.STANDARD_STRICT, cookieSpecProvider)
                .build();

        CloseableHttpClient httpclient = HttpClients.custom()
                .setSSLHostnameVerifier(hostnameVerifier)
                .setDefaultCookieSpecRegistry(cookieSpecRegistry)
                .build();
        try {

            HttpGet httpget = new HttpGet("https://httpbin.org/");

            System.out.println("executing request " + httpget.getRequestLine());

            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                HttpEntity entity = response.getEntity();

                System.out.println("----------------------------------------");
                System.out.println(response.getStatusLine());
                EntityUtils.consume(entity);
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }
    }
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:44,代码来源:ClientCustomPublicSuffixList.java


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