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


Java BasicClientCookie.setDomain方法代码示例

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


在下文中一共展示了BasicClientCookie.setDomain方法的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: saveCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
private static void saveCookie(String url){
	String cookie = CookieManager.getInstance().getCookie(url);
	if(cookie !=null && !cookie.equals("")){  
           String[] cookies = cookie.split(";");  
           for(int i=0; i< cookies.length; i++){  
               String[] nvp = cookies[i].split("=");  
               BasicClientCookie c = new BasicClientCookie(nvp[0], nvp[1]);  
               //c.setVersion(0);  
               c.setDomain("kyfw.12306.cn");
               MyCookieStore myCookieStore = null;
               if (MyApp.getInstance().getCommonBInfo().getHttpHelper().getHttpClient().getCookieStore()
               		instanceof MyCookieStore){
               	myCookieStore = (MyCookieStore)MyApp.getInstance().getCommonBInfo().getHttpHelper().getHttpClient().getCookieStore();
               }
               if (myCookieStore != null){
               	myCookieStore.addCookie(c);
               }
           }
      }  
	CookieSyncManager.getInstance().sync();
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:22,代码来源:WebViewUtil.java

示例4: 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

示例5: 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

示例6: 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

示例7: storeCookie

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
private String storeCookie(CloseableHttpResponse response) {

        Header cookieHeader = response.getFirstHeader("set-cookie");

        if (cookieHeader != null) {
            mTokenHeader = cookieHeader.getValue();
            String token = mTokenHeader.substring(8, mTokenHeader.indexOf(';'));
            mCookieStore.clear();

            BasicClientCookie cookie = new BasicClientCookie(BBOX_COOKIE_NAME, token);

            cookie.setDomain(BBOX_HOST);
            mCookieStore.addCookie(cookie);

            return token;
        }
        return null;
    }
 
开发者ID:bertrandmartel,项目名称:bboxapi-router,代码行数:19,代码来源:BboxApi.java

示例8: 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,项目名称:fusion-client-tools,代码行数:26,代码来源:FusionPipelineClient.java

示例9: 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

示例10: 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

示例11: initRequest

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Override
protected void initRequest(HttpUriRequest request)
{
	super.initRequest(request);
	
	// Set the timezone cookie
	TimeZone tz = TimeZone.getDefault();
	int utcOffsetMinutes = tz.getOffset(System.currentTimeMillis())/(1000*60);
	
	BasicClientCookie cookie = new BasicClientCookie("UtcOffsetMinutes",
			String.valueOf(utcOffsetMinutes));
	cookie.setPath("/");
	cookie.setDomain(".xbox.com");
	
	mHttpClient.getCookieStore().addCookie(cookie);
}
 
开发者ID:0xe1f,项目名称:Spark360,代码行数:17,代码来源:XboxLiveParser.java

示例12: activateBrowserfeatures

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
@Override
public void activateBrowserfeatures(final Upload upload) throws UnirestException {

	// Create a local instance of cookie store
	// Populate cookies if needed
	final CookieStore cookieStore = new BasicCookieStore();
	for (final PersistentCookieStore.SerializableCookie serializableCookie : upload.getAccount().getSerializeableCookies()) {
		final BasicClientCookie cookie = new BasicClientCookie(serializableCookie.getCookie().getName(), serializableCookie.getCookie().getValue());
		cookie.setDomain(serializableCookie.getCookie().getDomain());
		cookieStore.addCookie(cookie);
	}

	final HttpClient client = HttpClientBuilder.create().useSystemProperties().setDefaultCookieStore(cookieStore).build();
	Unirest.setHttpClient(client);

	final HttpResponse<String> response = Unirest.get(String.format(VIDEO_EDIT_URL, upload.getVideoid())).asString();

	changeMetadata(response.getBody(), upload);

	final RequestConfig clientConfig = RequestConfig.custom().setConnectTimeout(600000).setSocketTimeout(600000).build();
	Unirest.setHttpClient(HttpClientBuilder.create().setDefaultRequestConfig(clientConfig).build());
}
 
开发者ID:dennisfischer,项目名称:simplejavayoutubeuploader,代码行数:23,代码来源:AbstractMetadataService.java

示例13: 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

示例14: getAllCookies

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
public List<Cookie> getAllCookies() {
	List<Cookie> cookies = new ArrayList<Cookie>();

	Cursor cursor = db
			.query(TABLE_NAME, null, null, null, null, null, null);

	for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
		String name = cursor.getString(cursor.getColumnIndex(Column.NAME));
		String value = cursor
				.getString(cursor.getColumnIndex(Column.VALUE));

		BasicClientCookie cookie = new BasicClientCookie(name, value);

		cookie.setComment(cursor.getString(cursor
				.getColumnIndex(Column.COMMENT)));
		cookie.setDomain(cursor.getString(cursor
				.getColumnIndex(Column.DOMAIN)));
		long expireTime = cursor.getLong(cursor
				.getColumnIndex(Column.EXPIRY_DATE));
		if (expireTime != 0) {
			cookie.setExpiryDate(new Date(expireTime));
		}
		cookie.setPath(cursor.getString(cursor.getColumnIndex(Column.PATH)));
		cookie.setSecure(cursor.getInt(cursor.getColumnIndex(Column.SECURE)) == 1);
		cookie.setVersion(cursor.getInt(cursor
				.getColumnIndex(Column.VERSION)));

		cookies.add(cookie);
	}

	cursor.close();

	return cookies;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:35,代码来源:MyCookieDBManager.java

示例15: readObject

import org.apache.http.impl.cookie.BasicClientCookie; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:12,代码来源:SerializableCookie.java


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