Java 类org.apache.http.impl.cookie.DefaultCookieSpecProvider 实例源码

项目:purecloud-iot    文件:CookieSpecRegistries.java   
/**
 * 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());
}
项目:purecloud-iot    文件:TestRequestAddCookies.java   
@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();
}
项目:tip    文件:HttpsClient.java   
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));
}