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


Java BasicClientCookie.setPath方法代码示例

本文整理汇总了Java中org.apache.http.impl.cookie.BasicClientCookie.setPath方法的典型用法代码示例。如果您正苦于以下问题:Java BasicClientCookie.setPath方法的具体用法?Java BasicClientCookie.setPath怎么用?Java BasicClientCookie.setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.impl.cookie.BasicClientCookie的用法示例。


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

示例1: buildCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Override
protected void buildCookie(com.intuit.karate.http.Cookie c) {
    BasicClientCookie cookie = new BasicClientCookie(c.getName(), c.getValue());
    for (Entry<String, String> entry : c.entrySet()) {
        switch (entry.getKey()) {
            case DOMAIN:
                cookie.setDomain(entry.getValue());
                break;
            case PATH:
                cookie.setPath(entry.getValue());
                break;
        }
    }
    if (cookie.getDomain() == null) {
        cookie.setDomain(uriBuilder.getHost());
    }
    cookieStore.addCookie(cookie);
}
 
开发者ID:intuit,项目名称:karate,代码行数:19,代码来源:ApacheHttpClient.java

示例2: getuCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public static CookieStore getuCookie() {
    CookieStore uCookie = new BasicCookieStore();
    try {
        String COOKIE_S_LINKDATA = LemallPlatform.getInstance().getCookieLinkdata();
        if (!TextUtils.isEmpty(COOKIE_S_LINKDATA)) {
            String[] cookies = COOKIE_S_LINKDATA.split("&");
            for (String item : cookies) {
                String[] keyValue = item.split(SearchCriteria.EQ);
                if (keyValue.length == 2) {
                    if (OtherUtil.isContainsChinese(keyValue[1])) {
                        keyValue[1] = URLEncoder.encode(keyValue[1], "UTF-8");
                    }
                    BasicClientCookie cookie = new BasicClientCookie(keyValue[0], keyValue[1]);
                    cookie.setVersion(0);
                    cookie.setDomain(".lemall.com");
                    cookie.setPath("/");
                    uCookie.addCookie(cookie);
                }
            }
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return uCookie;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:AsyncHttpClient.java

示例3: saveCookies

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public void saveCookies() throws IOException {

        CookieManager cm = getWebClient().getCookieManager();
        ArrayList<BasicClientCookie> list = new ArrayList<>();

        for (Cookie c : cm.getCookies()) {
            BasicClientCookie bc = new BasicClientCookie(c.getName(), c.getValue());
            bc.setDomain(c.getDomain());
            bc.setPath(c.getPath());
            list.add(bc);
        }


        File cookiesFile = Directories.META.getDir("cookies.json");
        if (cookiesFile.exists()) {
            cookiesFile.delete();
        }

        String o = new Gson().toJson(list);
        FileUtils.writeByteArrayToFile(cookiesFile, o.getBytes());

    }
 
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:AudibleScraper.java

示例4: createContext

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Override
public BasicHttpContext createContext(final HttpHost targetHost) {

    final CookieStore cookieStore = new BasicCookieStore();

    final BasicClientCookie clientCookie =
            new BasicClientCookie(cookie.getName(), cookie.getValue());
    clientCookie.setDomain(targetHost.getHostName());
    clientCookie.setPath("/");
    cookieStore.addCookie(clientCookie);

    final BasicHttpContext context = new BasicHttpContext();
    context.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);

    return context;
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:17,代码来源:UseCookieConfigurator.java

示例5: authToGoogle

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
/**
 * Authentication with google account
 * @param cookies cookies list keys from google auth
 * @param login username associated to zds login
 * @param id user id on ZdS associated to login
 */
public void authToGoogle(List<HttpCookie> cookies, String login, String id) {
    if(login != null && id != null) {
        this.login = login;
        this.idUser = id;
        log.info("L'identifiant de l'utilisateur " + this.login + " est : " + idUser);
        cookieStore = new BasicCookieStore();
        for(HttpCookie cookie:cookies) {
            BasicClientCookie c = new BasicClientCookie(cookie.getName(), cookie.getValue());
            c.setDomain(cookie.getDomain());
            c.setPath(cookie.getPath());
            c.setSecure(cookie.getSecure());
            c.setVersion(cookie.getVersion());
            c.setComment(cookie.getComment());
            cookieStore.addCookie(c);
        }
        context.setCookieStore(cookieStore);
        this.authenticated = true;
    }
    else {
        log.debug("Le login de l'utilisateur n'a pas pu être trouvé");
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:29,代码来源:ZdsHttp.java

示例6: batchCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
/**
 * batchCookies
 * 
 * @param cookiestring
 *            the cookie string, eg.:"a=b;c=a"
 * @param domain
 *            the domain
 * @param path
 *            the path
 * @param expired
 *            the expired date
 */
public synchronized void batchCookie(String cookiestring, String domain, String path, Date expired) {
	String[] ss = X.split(cookiestring, ";");
	for (String s : ss) {
		StringFinder sf = StringFinder.create(s);
		String name = sf.nextTo("=");
		String value = sf.remain();
		if (!X.isEmpty(name)) {
			removeCookie(name, domain, path);

			BasicClientCookie c = new BasicClientCookie(name, value);
			c.setDomain(domain);
			c.setPath(X.isEmpty(path) ? "/" : path);
			c.setExpiryDate(expired);
			cookies.addCookie(c);
		}
	}
}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:30,代码来源:Http.java

示例7: clearCookieForHost

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
protected synchronized void clearCookieForHost(String sessionHost) throws Exception {
  Cookie sessionCookie = null;
  for (Cookie cookie : cookieStore.getCookies()) {
    String cookieDomain = cookie.getDomain();
    if (cookieDomain != null) {
      if (sessionHost.equals(cookieDomain) ||
          sessionHost.indexOf(cookieDomain) != -1 ||
          cookieDomain.indexOf(sessionHost) != -1) {
        sessionCookie = cookie;
        break;
      }
    }
  }

  if (sessionCookie != null) {
    BasicClientCookie httpCookie =
        new BasicClientCookie(sessionCookie.getName(), sessionCookie.getValue());
    httpCookie.setExpiryDate(new Date(0));
    httpCookie.setVersion(1);
    httpCookie.setPath(sessionCookie.getPath());
    httpCookie.setDomain(sessionCookie.getDomain());
    cookieStore.addCookie(httpCookie);
  }

  cookieStore.clearExpired(new Date()); // this should clear the cookie
}
 
开发者ID:lucidworks,项目名称:solr-hadoop-common,代码行数:27,代码来源:FusionPipelineClient.java

示例8: createApacheCookieStore

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public static ConcurrentCookieJar createApacheCookieStore(HttpDownloaderConfig config) {
    List<HttpDownloaderConfig.Cookie> cookies = config.getCookies();
    if (cookies == null) {
        return null;
    }
    ConcurrentCookieJar store = new ConcurrentCookieJar();
    for (HttpDownloaderConfig.Cookie cookie : cookies) {
        String[] values = cookie.cookie.split("; ");
        for (int i = 0; i < values.length; i++) {
            String[] kv = values[i].split("=", 2);
            BasicClientCookie cc = new BasicClientCookie(kv[0], kv[1]);
            cc.setPath(cookie.path);
            cc.setDomain(cookie.domain);
            store.addCookie(cc);
        }
    }
    return store;
}
 
开发者ID:ViDA-NYU,项目名称:ache,代码行数:19,代码来源:FetcherFactory.java

示例9: testCookiesAreCapturedWhenRequested

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Test
public void testCookiesAreCapturedWhenRequested() throws IOException {
    proxy.setCaptureContent(true);
    proxy.newHar("Test");

    BasicClientCookie cookie = new BasicClientCookie("foo", "bar");
    cookie.setDomain("127.0.0.1");
    cookie.setPath("/");
    client.getCookieStore().addCookie(cookie);

    // set the cookie on the server side
    String body = IOUtils.readFully(client.execute(new HttpGet(ECHO_URL)).getEntity().getContent());
    System.out.println(body);

    Har har = proxy.getHar();
    HarEntry entry = har.getLog().getEntries().get(0);
    HarCookie harCookie = entry.getRequest().getCookies().get(0);
    Assert.assertEquals("foo", harCookie.getName());
    Assert.assertEquals("bar", harCookie.getValue());
}
 
开发者ID:epam,项目名称:Wilma,代码行数:21,代码来源:CookieTest.java

示例10: shareCookies

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
/**
 * Share the cookies with HttpClientTask
 */
public void shareCookies(){
  Object store = getCookieStore();
  if (store == null){
    store = new BasicCookieStore();
    this.getParametersInner().put(HttpClientTask.PARAM_HTTP_COOKIES, store);
  }
  
  CookieStore cookieStore = (CookieStore)store; 
  for (Cookie cookie : this.getDriver().manage().getCookies()){
    BasicClientCookie newCookie = new BasicClientCookie(cookie.getName(), cookie.getValue());
    newCookie.setDomain(cookie.getDomain());
    newCookie.setPath(cookie.getPath());
    newCookie.setExpiryDate(cookie.getExpiry());
    newCookie.setSecure(cookie.isSecure());
    cookieStore.addCookie(newCookie);
  }
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:21,代码来源:GebDetectivePage.java

示例11: clearCookieForHost

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
protected synchronized void clearCookieForHost(String sessionHost) throws Exception {
  Cookie sessionCookie = null;
  for (Cookie cookie : cookieStore.getCookies()) {
    String cookieDomain = cookie.getDomain();
    if (cookieDomain != null) {
      if (sessionHost.equals(cookieDomain) ||
              sessionHost.indexOf(cookieDomain) != -1 ||
              cookieDomain.indexOf(sessionHost) != -1) {
        sessionCookie = cookie;
        break;
      }
    }
  }

  if (sessionCookie != null) {
    BasicClientCookie httpCookie = new BasicClientCookie(sessionCookie.getName(), sessionCookie.getValue());
    httpCookie.setExpiryDate(new Date(0));
    httpCookie.setVersion(1);
    httpCookie.setPath(sessionCookie.getPath());
    httpCookie.setDomain(sessionCookie.getDomain());
    cookieStore.addCookie(httpCookie);
  }

  cookieStore.clearExpired(new Date()); // this should clear the cookie
}
 
开发者ID:lucidworks,项目名称:solr-scale-tk,代码行数:26,代码来源:FusionPipelineClient.java

示例12: create

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Override
public DefaultHttpClient create(final HttpMethod method, final URI uri) {
  final CookieStore cookieStore = new BasicCookieStore();

  // Populate cookies if needed
  final BasicClientCookie cookie = new BasicClientCookie("name", "value");
  cookie.setVersion(0);
  cookie.setDomain(".mycompany.com");
  cookie.setPath("/");
  cookieStore.addCookie(cookie);

  final DefaultHttpClient httpClient = super.create(method, uri);
  httpClient.setCookieStore(cookieStore);

  return httpClient;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:CookieHttpClientFactory.java

示例13: getAccessToken

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public static String getAccessToken(String sessionId, String csrfToken)
throws Exception {
	DefaultHttpClient client = new DefaultHttpClient();
	client.getParams().setBooleanParameter(
			"http.protocol.handle-redirects", false);
	CookieStore cookies = new BasicCookieStore();
	BasicClientCookie csrfCookie = new BasicClientCookie(
			"csrftoken", csrfToken);
	csrfCookie.setDomain(Urls.OAUTH_HOSTNAME);
	csrfCookie.setPath("/");
	cookies.addCookie(csrfCookie);
	BasicClientCookie sessionCookie = new BasicClientCookie(
			"sessionid", sessionId);
	sessionCookie.setDomain(Urls.OAUTH_HOSTNAME);
	sessionCookie.setPath("/");
	cookies.addCookie(sessionCookie);		
	client.setCookieStore(cookies);
	
	authorizeClient(client);
	return getAccessToken(client, 
			getAuthorizationCode(client, 
					authorizeClient(client, csrfToken)));
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:24,代码来源:OAuth.java

示例14: convertCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
/**
 * Converts Selenium cookie to Apache http client.
 * @param browserCookie selenium cookie.
 * @return http client format.
 */
protected ClientCookie convertCookie(Cookie browserCookie) {
    BasicClientCookie cookie = new BasicClientCookie(browserCookie.getName(), browserCookie.getValue());
    String domain = browserCookie.getDomain();
    if (domain != null && domain.startsWith(".")) {
        // http client does not like domains starting with '.', it always removes it when it receives them
        domain = domain.substring(1);
    }
    cookie.setDomain(domain);
    cookie.setPath(browserCookie.getPath());
    cookie.setExpiryDate(browserCookie.getExpiry());
    cookie.setSecure(browserCookie.isSecure());
    if (browserCookie.isHttpOnly()) {
        cookie.setAttribute("httponly", "");
    }
    return cookie;
}
 
开发者ID:fhoeben,项目名称:hsac-fitnesse-fixtures,代码行数:22,代码来源:CookieConverter.java

示例15: importCookies

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public static void importCookies(CookieStore cookieStore, JSONArray cookies) {
	cookieStore.clear();
	
	for (int i = 0; i < cookies.length(); i++) {
		try {
			JSONObject json = cookies.getJSONObject(i);
			if (json.has("domain") && json.has("expiryDate")
				&& json.has("name") && json.has("value")) {
				BasicClientCookie cookie = new BasicClientCookie(json.getString("name"), json.getString("value"));
				cookie.setDomain(json.getString("domain"));
				cookie.setPath(json.getString("path"));
				long expiryTs = json.getLong("expiryDate");
				cookie.setExpiryDate(new Date(expiryTs));
				cookieStore.addCookie(cookie);
			}
		} catch (JSONException e) {
			logger.error(e.getMessage(), e);
		}
	}
}
 
开发者ID:askeing,项目名称:jplurk,代码行数:21,代码来源:ISettings.java


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