Search in sources :

Example 1 with DefaultCookieSpecProvider

use of org.apache.http.impl.cookie.DefaultCookieSpecProvider in project fess-crawler by codelibs.

the class HcHttpClient method buildCookieSpecRegistry.

protected Lookup<CookieSpecProvider> buildCookieSpecRegistry() {
    if (cookieSpecRegistry != null) {
        return cookieSpecRegistry;
    }
    final PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.getDefault();
    final CookieSpecProvider defaultProvider = new DefaultCookieSpecProvider(CompatibilityLevel.DEFAULT, publicSuffixMatcher, cookieDatePatterns, false);
    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()).build();
}
Also used : RFC6265CookieSpecProvider(org.apache.http.impl.cookie.RFC6265CookieSpecProvider) IgnoreSpecProvider(org.apache.http.impl.cookie.IgnoreSpecProvider) CookieSpecProvider(org.apache.http.cookie.CookieSpecProvider) DefaultCookieSpecProvider(org.apache.http.impl.cookie.DefaultCookieSpecProvider) RFC6265CookieSpecProvider(org.apache.http.impl.cookie.RFC6265CookieSpecProvider) NetscapeDraftSpecProvider(org.apache.http.impl.cookie.NetscapeDraftSpecProvider) PublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher) DefaultCookieSpecProvider(org.apache.http.impl.cookie.DefaultCookieSpecProvider)

Example 2 with DefaultCookieSpecProvider

use of org.apache.http.impl.cookie.DefaultCookieSpecProvider in project gradle by gradle.

the class HttpClientConfigurer method configureCookieSpecRegistry.

private void configureCookieSpecRegistry(HttpClientBuilder builder) {
    PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.getDefault();
    builder.setPublicSuffixMatcher(publicSuffixMatcher);
    // Add more data patterns to the default configuration to work around https://github.com/gradle/gradle/issues/1596
    final CookieSpecProvider defaultProvider = new DefaultCookieSpecProvider(DefaultCookieSpecProvider.CompatibilityLevel.DEFAULT, publicSuffixMatcher, new String[] { // Netscape expires pattern
    "EEE, dd-MMM-yy HH:mm:ss z", DateUtils.PATTERN_RFC1036, DateUtils.PATTERN_ASCTIME, DateUtils.PATTERN_RFC1123 }, false);
    final CookieSpecProvider laxStandardProvider = new RFC6265CookieSpecProvider(RFC6265CookieSpecProvider.CompatibilityLevel.RELAXED, publicSuffixMatcher);
    final CookieSpecProvider strictStandardProvider = new RFC6265CookieSpecProvider(RFC6265CookieSpecProvider.CompatibilityLevel.STRICT, publicSuffixMatcher);
    builder.setDefaultCookieSpecRegistry(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()).build());
}
Also used : RFC6265CookieSpecProvider(org.apache.http.impl.cookie.RFC6265CookieSpecProvider) IgnoreSpecProvider(org.apache.http.impl.cookie.IgnoreSpecProvider) CookieSpecProvider(org.apache.http.cookie.CookieSpecProvider) DefaultCookieSpecProvider(org.apache.http.impl.cookie.DefaultCookieSpecProvider) RFC6265CookieSpecProvider(org.apache.http.impl.cookie.RFC6265CookieSpecProvider) NetscapeDraftSpecProvider(org.apache.http.impl.cookie.NetscapeDraftSpecProvider) PublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher) DefaultCookieSpecProvider(org.apache.http.impl.cookie.DefaultCookieSpecProvider)

Aggregations

PublicSuffixMatcher (org.apache.http.conn.util.PublicSuffixMatcher)2 CookieSpecProvider (org.apache.http.cookie.CookieSpecProvider)2 DefaultCookieSpecProvider (org.apache.http.impl.cookie.DefaultCookieSpecProvider)2 IgnoreSpecProvider (org.apache.http.impl.cookie.IgnoreSpecProvider)2 NetscapeDraftSpecProvider (org.apache.http.impl.cookie.NetscapeDraftSpecProvider)2 RFC6265CookieSpecProvider (org.apache.http.impl.cookie.RFC6265CookieSpecProvider)2