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


Java Cookie类代码示例

本文整理汇总了Java中com.ning.http.client.cookie.Cookie的典型用法代码示例。如果您正苦于以下问题:Java Cookie类的具体用法?Java Cookie怎么用?Java Cookie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testGetCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
@Test
public void testGetCookie() throws Exception {
    NewCookie cookie1 = ParsecHttpUtil.getCookie(new Cookie(
        "cookie1_name",
        "cookie1_value",
        false,
        null,
        "cookie1_path",
        1,
        true,
        true
    ));

    assertEquals("cookie1_name", cookie1.getName());
    assertEquals("cookie1_value", cookie1.getValue());
    assertEquals(null, cookie1.getDomain());
    assertEquals("cookie1_path", cookie1.getPath());
    assertEquals(null, cookie1.getExpiry());
    assertEquals(1, cookie1.getMaxAge());
    assertTrue(cookie1.isSecure());
    assertTrue(cookie1.isHttpOnly());
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:23,代码来源:ParsecHttpUtilTest.java

示例2: recordCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
protected void recordCookie(com.ning.http.client.Request httpRequest, Trace trace) {
    if (cookieSampler.isSampling()) {
        Collection<Cookie> cookies = httpRequest.getCookies();

        if (cookies.isEmpty()) {
            return;
        }

        StringBuilder sb = new StringBuilder(cookieDumpSize * 2);
        Iterator<Cookie> iterator = cookies.iterator();
        while (iterator.hasNext()) {
            Cookie cookie = iterator.next();
            sb.append(cookie.getName()).append("=").append(cookie.getValue());
            if (iterator.hasNext()) {
                sb.append(",");
            }
        }
        trace.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.drop(sb.toString(), cookieDumpSize));
    }
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:21,代码来源:ExecuteRequestInterceptor.java

示例3: recordCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
private void recordCookie(Request httpRequest, SpanEventRecorder recorder) {
    if (cookieSampler.isSampling()) {
        Collection<Cookie> cookies = httpRequest.getCookies();

        if (cookies.isEmpty()) {
            return;
        }

        StringBuilder sb = new StringBuilder(config.getCookieDumpSize() * 2);
        Iterator<Cookie> iterator = cookies.iterator();
        while (iterator.hasNext()) {
            Cookie cookie = iterator.next();
            sb.append(cookie.getName()).append('=').append(cookie.getValue());
            if (iterator.hasNext()) {
                sb.append(',');
            }
        }
        recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(sb.toString(), config.getCookieDumpSize()));
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:21,代码来源:ExecuteRequestInterceptor.java

示例4: storeCookies

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
public void storeCookies(TestCase testCase, List<Cookie> cookieLst) {
	int simNumber = testCase.getSimulationNumber()==null?0:testCase.getSimulationNumber();
	if(testCase.isServerApiAuth() || testCase.isServerApiTarget()) {
		simNumber = -1;
	} else if(testCase.isExternalApi()) {
		simNumber = -2;
	} else if(testCase.getSimulationNumber()==null) {
		simNumber = 0;
	}
	if(cookieLst!=null && cookies.get(simNumber)!=null)
	{
		for (Cookie cookie : cookieLst) {
			if(cookie.getValue()!=null)
			{
				cookies.get(simNumber).put(cookie.getName(), cookie.getValue());
			}
		}
	}
}
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:20,代码来源:WorkflowContextHandler.java

示例5: getCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
/**
 * Get {@link NewCookie} from Ning {@link Cookie}.
 *
 * @param ningCookie Ning {@link Cookie}
 * @return {@link NewCookie}
 */
public static NewCookie getCookie(final Cookie ningCookie) {
    return new NewCookie(
        ningCookie.getName(),
        ningCookie.getValue(),
        ningCookie.getPath(),
        ningCookie.getDomain(),
        "",
        (int) ningCookie.getMaxAge(),
        ningCookie.isSecure(),
        ningCookie.isHttpOnly()
    );
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:19,代码来源:ParsecHttpUtil.java

示例6: setCookies

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
private void setCookies(Collection<Cookie> cookies) {
    this.cookies.clear();

    if (cookies != null) {
        this.cookies.addAll(cookies);
    }
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:8,代码来源:AsyncPackageManagerClient.java

示例7: addContext

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
private AsyncHttpClient.BoundRequestBuilder addContext(AsyncHttpClient.BoundRequestBuilder builder) {
    if (builder != null) {
        if (this.realm != null) {
            builder.setRealm(this.realm);
        }
        for (Cookie cookie : this.cookies) {
            builder.addCookie(cookie);
        }
    }
    return builder;
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:12,代码来源:AsyncPackageManagerClient.java

示例8: setResponse

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
public void setResponse(String endpoint, Response response) throws IOException {

        Integer statusCode = response.getStatusCode();
        String httpResponse = response.getResponseBody();
        List<Cookie> cookies = response.getCookies();
        this.response = new HttpResponse(statusCode, httpResponse, cookies);
    }
 
开发者ID:Stratio,项目名称:bdt,代码行数:8,代码来源:CommonG.java

示例9: setDCOSCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
public void setDCOSCookie(String DCOSsecret, String email) throws Exception {
    final JWTSigner signer = new JWTSigner(DCOSsecret);
    final HashMap<String, Object> claims = new HashMap();
    claims.put("uid", email);
    final String jwt = signer.sign(claims);
    Cookie cookie = new Cookie("dcos-acs-auth-cookie", jwt, false, "", "", 99999, false, false);
    List<Cookie> cookieList = new ArrayList<Cookie>();
    cookieList.add(cookie);
    commonspec.setCookies(cookieList);
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:11,代码来源:GivenGSpec.java

示例10: setGoSecSSOCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
/**
 * Generate token to authenticate in gosec SSO
 * @param ssoHost current sso host
 * @param userName username
 * @param passWord password
 * @throws Exception exception
 */
@Given("^I set sso token using host '(.+?)' with user '(.+?)' and password '(.+?)'$")
public void setGoSecSSOCookie(String ssoHost, String userName, String passWord) throws Exception {
    HashMap<String, String> ssoCookies = new GosecSSOUtils(ssoHost, userName, passWord).ssoTokenGenerator();
    String[] tokenList = {"user", "dcos-acs-auth-cookie"};
    List<Cookie> cookiesAtributes = addSsoToken(ssoCookies, tokenList);

    commonspec.setCookies(cookiesAtributes);
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:16,代码来源:GivenGSpec.java

示例11: addSsoToken

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
public List<Cookie> addSsoToken(HashMap<String, String> ssoCookies, String[] tokenList) {
    List<Cookie> cookiesAttributes = new ArrayList<>();

    for (String tokenKey : tokenList) {
        cookiesAttributes.add(new Cookie(tokenKey, ssoCookies.get(tokenKey),
                false, null,
                null, 999999, false, false));
    }
    return cookiesAttributes;
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:11,代码来源:GivenGSpec.java

示例12: getCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
/**
 * Get only one cookie, using the cookie name.
 */
@Override
public Cookie getCookie(String name) {
    for (Cookie cookie : ahcResponse.getCookies()) {
        // safe -- cookie.getName() will never return null
        if (cookie.getName().equals(name)) {
            return cookie;
        }
    }
    return null;
}
 
开发者ID:mcoira,项目名称:async-rest-client,代码行数:14,代码来源:NingRestResponse.java

示例13: testOptionalCachingOnJSESSIONIDCookie

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
@Test
public void testOptionalCachingOnJSESSIONIDCookie() throws Exception {
    Map<String,String> filterInitParams = new HashMap<String,String>(1,1.0f) {{
        put(PublishToMemcachedFilter.MEMCACHED_KEY_PARAM,"$scheme$request_method$uri$args?$cookie_jsessionid?");
        put(PublishToMemcachedFilter.MEMCACHED_EXPIRY,"10");
    }};
    server.setupServlet3Filter("localhost:" + memcached.getPort(),null,filterInitParams);
    String url = server.setupServlet("/date/*","date","org.greencheek.web.filter.memcached.servlets.JSESSIONIDServlet",true);

    assertTrue(server.startTomcat());
    url = server.replacePort(url);
    Response response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));

    List<Cookie> cookies = response.getCookies();
    String sessionId = getSessionID(response);

    response = executeGetRequest(url,cookies);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url,cookies);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));
    assertEquals(sessionId, getSessionID(response));

    Cookie c = cookies.get(0);
    Cookie madeupJsessionId = new Cookie("JSESSIONID","xx","xx",c.getDomain(),c.getPath(),
            c.getExpires(),c.getMaxAge(),c.isSecure(),c.isHttpOnly());

    response = executeGetRequest(url, Collections.singletonList(madeupJsessionId));
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));
    assertNotEquals(sessionId, getSessionID(response));

}
 
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:37,代码来源:TestFilterConfiguration.java

示例14: executeGetRequest

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
private Response executeGetRequest(String url,List<Cookie> cookies) throws Exception {
    AsyncHttpClient.BoundRequestBuilder rBuilder = server.getHttpClient().prepareGet(url);
    for(Cookie c : cookies) {
        rBuilder.addCookie(c);
    }
    Request r = rBuilder.build();
    return server.getHttpClient().executeRequest(r).get();
}
 
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:9,代码来源:TestFilterConfiguration.java

示例15: getCookieString

import com.ning.http.client.cookie.Cookie; //导入依赖的package包/类
private String getCookieString(Response response, String key) {
    for(Cookie c : response.getCookies()) {
        if(c.getName().equalsIgnoreCase(key)) {
            return c.getValue();
        }
    }
    return "";
}
 
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:9,代码来源:TestFilterConfiguration.java


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