Java 类org.apache.http.cookie.CookieSpecFactory 实例源码

项目:Wilma    文件:BrowserMobHttpClient.java   
public void prepareForBrowser() {
    // Clear cookies, let the browser handle them
    httpClient.setCookieStore(new BlankCookieStore());
    httpClient.getCookieSpecs().register("easy", new CookieSpecFactory() {
        @Override
        public CookieSpec newInstance(final HttpParams params) {
            return new BrowserCompatSpec() {
                @Override
                public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException {
                    // easy!
                }
            };
        }
    });
    httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, "easy");
    decompress = false;
    setFollowRedirects(false);
}
项目:Android-Heatmap    文件:MainActivity.java   
private void prepairCookieStore(DefaultHttpClient client) {

    client.setCookieStore(cookieStore);

    CookieSpecFactory csf = new CookieSpecFactory() {
          public CookieSpec newInstance(HttpParams params) {
              return new BrowserCompatSpec() {
                  @Override
                  public void validate(Cookie cookie, CookieOrigin origin)
                  throws MalformedCookieException {
                    // not filtering; accept all cookies
                    Log.d(this.toString(),"cookies");
                  }
              };
          }
      };
      client.getCookieSpecs().register("all", csf);
      client.getParams().setParameter(
           ClientPNames.COOKIE_POLICY, "all"); 
}