本文整理了Java中org.apache.http.cookie.Cookie.getValue()
方法的一些代码示例,展示了Cookie.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.getValue()
方法的具体详情如下:
包路径:org.apache.http.cookie.Cookie
类名称:Cookie
方法名:getValue
[英]Returns the value.
[中]返回值。
代码示例来源:origin: alibaba/canal
while (iteratorCookie.hasNext()) {
Cookie cookie = iteratorCookie.next();
cookieStr.append(cookie.getName() + "=" + cookie.getValue());
if (iteratorCookie.hasNext()) {
cookieStr.append(";");
代码示例来源:origin: yaphone/itchat4j
public static String getCookie(String name) {
List<Cookie> cookies = cookieStore.getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equalsIgnoreCase(name)) {
return cookie.getValue();
}
}
return null;
}
代码示例来源:origin: internetarchive/heritrix3
public void addCookie(Cookie cookie) {
if (isCookieCountMaxedForDomain(cookie.getDomain())) {
logger.log(
Level.FINEST,
"Maximum number of cookies reached for domain "
+ cookie.getDomain() + ". Will not add new cookie "
+ cookie.getName() + " with value "
+ cookie.getValue());
return;
}
addCookieImpl(cookie);
}
代码示例来源:origin: robovm/robovm
public List<Header> formatCookies(final List<Cookie> cookies) {
if (cookies == null) {
throw new IllegalArgumentException("List of cookies may not be null");
}
if (cookies.isEmpty()) {
throw new IllegalArgumentException("List of cookies may not be empty");
}
CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
buffer.append(SM.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (i > 0) {
buffer.append("; ");
}
buffer.append(cookie.getName());
buffer.append("=");
String s = cookie.getValue();
if (s != null) {
buffer.append(s);
}
}
List<Header> headers = new ArrayList<Header>(1);
headers.add(new BufferedHeader(buffer));
return headers;
}
代码示例来源:origin: robovm/robovm
public List<Header> formatCookies(final List<Cookie> cookies) {
if (cookies == null) {
throw new IllegalArgumentException("List of cookies may not be null");
}
if (cookies.isEmpty()) {
throw new IllegalArgumentException("List of cookies may not be empty");
}
CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
buffer.append(SM.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (i > 0) {
buffer.append("; ");
}
buffer.append(cookie.getName());
String s = cookie.getValue();
if (s != null) {
buffer.append("=");
buffer.append(s);
}
}
List<Header> headers = new ArrayList<Header>(1);
headers.add(new BufferedHeader(buffer));
return headers;
}
代码示例来源:origin: cloudfoundry/uaa
public static HttpHeaders getHeaders(CookieStore cookies) {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML, MediaType.ALL));
for (org.apache.http.cookie.Cookie cookie : cookies.getCookies()) {
headers.add("Cookie", cookie.getName() + "=" + cookie.getValue());
}
return headers;
}
代码示例来源:origin: internetarchive/heritrix3
line.append(cookie.getName());
line.append(tab);
line.append(cookie.getValue() != null ? cookie.getValue() : "");
line.append("\n");
out.write(line.toString().getBytes());
代码示例来源:origin: rest-assured/rest-assured
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
final CookieOrigin cookieOrigin = cookieOriginFromUri(requestSpec.getURI());
for (Cookie cookie : cookieStore.getCookies()) {
if (cookieSpec.match(cookie, cookieOrigin) && !requestSpec.getCookies().hasCookieWithName(cookie.getName())) {
requestSpec.cookie(cookie.getName(), cookie.getValue());
}
}
final Response response = ctx.next(requestSpec, responseSpec);
List<Cookie> responseCookies = extractResponseCookies(response, cookieOrigin);
cookieStore.addCookies(responseCookies.toArray(new Cookie[0]));
return response;
}
代码示例来源:origin: robovm/robovm
/**
* Return a string suitable for sending in a <tt>"Cookie"</tt> header
* as defined in RFC 2109 for backward compatibility with cookie version 0
* @param buffer The char array buffer to use for output
* @param cookie The {@link Cookie} to be formatted as string
* @param version The version to use.
*/
protected void formatCookieAsVer(final CharArrayBuffer buffer,
final Cookie cookie, int version) {
formatParamAsVer(buffer, cookie.getName(), cookie.getValue(), version);
if (cookie.getPath() != null) {
if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.PATH_ATTR)) {
buffer.append("; ");
formatParamAsVer(buffer, "$Path", cookie.getPath(), version);
}
}
if (cookie.getDomain() != null) {
if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
buffer.append("; ");
formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version);
}
}
}
代码示例来源:origin: NationalSecurityAgency/timely
public TimelyEndpointConfig(Cookie sessionCookie) {
if (null != sessionCookie) {
this.sessionCookie = String.format(FORMAT, sessionCookie.getName(), sessionCookie.getValue());
}
}
代码示例来源:origin: org.jboss.as/jboss-as-testsuite-shared
public static String getSessionIdValueFromState(CookieStore cookieStore) {
String sessionID = null;
for (Cookie cookie : cookieStore.getCookies()) {
if ("JSESSIONID".equalsIgnoreCase(cookie.getName())) {
sessionID = cookie.getValue();
break;
}
}
return sessionID;
}
代码示例来源:origin: SpringForAll/springcloud-thoth
private static void setCookie(HttpRequest request, Cookie[] cookies) {
if (cookies != null && cookies.length > 0) {
List<String> cookieStr = new LinkedList<>();
for (Cookie cookie : cookies) {
cookieStr.add(cookie.getName() + "=" + cookie.getValue());
}
request.setHeader("Cookie", StringUtils.join(cookieStr, "; "));
}
}
代码示例来源:origin: org.leapframework/leap-webunit
public synchronized void addCookie(final org.apache.http.cookie.Cookie cookie) {
if (cookie != null) {
log.debug("Add cookie : name={}, path={}, value={},", cookie.getName(), cookie.getPath(), cookie.getValue());
// first remove any old cookie that is equivalent
cookies.remove(cookie);
if (!cookie.isExpired(new Date())) {
cookies.add(cookie);
}
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients
/** Get login token cookie or null if not found */
private Cookie getLoginCookie(HttpContext context, String loginTokenName) {
for (Cookie cookie : HttpClientContext.adapt(context).getCookieStore().getCookies()) {
if (cookie.getName().equalsIgnoreCase(loginTokenName) && !cookie.getValue().isEmpty()) {
return cookie;
}
}
return null;
}
}
代码示例来源:origin: org.archive.heritrix/heritrix-modules
public void addCookie(Cookie cookie) {
if (isCookieCountMaxedForDomain(cookie.getDomain())) {
logger.log(
Level.FINEST,
"Maximum number of cookies reached for domain "
+ cookie.getDomain() + ". Will not add new cookie "
+ cookie.getName() + " with value "
+ cookie.getValue());
return;
}
addCookieImpl(cookie);
}
代码示例来源:origin: de.devbliss.apitester/apitester
Cookie(org.apache.http.cookie.Cookie cookie) {
this.name = cookie.getName();
this.value = cookie.getValue();
this.expires = cookie.getExpiryDate();
this.path = cookie.getPath();
this.domain = cookie.getDomain();
this.httpOnly = false;
this.secure = cookie.isSecure();
}
代码示例来源:origin: ViDA-NYU/ache
@Test
public void testApacheCookielInput() {
cookie.setDomain(".slides.com");
org.apache.http.cookie.Cookie resultCookie = CookieUtils.asApacheCookie(cookie);
assertTrue(resultCookie.getName().equals("key1"));
assertTrue(resultCookie.getValue().equals("value1"));
assertTrue(resultCookie.getDomain().equals(".slides.com"));
}
代码示例来源:origin: ViDA-NYU/ache
@Test
public void testApacheCookielInputNullDomain() {
org.apache.http.cookie.Cookie resultCookie = CookieUtils.asApacheCookie(cookie);
assertTrue(resultCookie.getName().equals("key1"));
assertTrue(resultCookie.getValue().equals("value1"));
assertTrue(resultCookie.getDomain() == null);
}
代码示例来源:origin: ViDA-NYU/ache
@Test
public void testApacheCookielInputNullValue() {
cookie.setValue(null);
org.apache.http.cookie.Cookie resultCookie = CookieUtils.asApacheCookie(cookie);
assertTrue(resultCookie.getName().equals("key1"));
assertTrue(resultCookie.getValue() == null);
}
代码示例来源:origin: ViDA-NYU/ache
@Test(expected = IllegalArgumentException.class)
public void testApacheCookielInputNullKey() {
cookie.setName(null);
org.apache.http.cookie.Cookie resultCookie = CookieUtils.asApacheCookie(cookie);
assertTrue(resultCookie.getName() == null);
assertTrue(resultCookie.getValue().equals("value1"));
}
内容来源于网络,如有侵权,请联系作者删除!