热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.net.HttpCookie.()方法的使用及代码示例

本文整理了Java中java.net.HttpCookie.<init>()方法的一些代码示例,展示了HttpCookie.<init&g

本文整理了Java中java.net.HttpCOOKIE.()方法的一些代码示例,展示了HttpCOOKIE.()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpCOOKIE.()方法的具体详情如下:
包路径:java.net.HttpCOOKIE
类名称:HttpCOOKIE
方法名:

HttpCOOKIE.介绍

[英]Creates a new COOKIE.
[中]创建一个新的COOKIE。

代码示例

代码示例来源:origin: stackoverflow.com

Response.AddHeader("Set-COOKIE", "COOKIEName=COOKIEValue; path=/;");
Response.SetCOOKIE(new HttpCOOKIE("session-id") { Value = Guid.NewGuid().ToString(), HttpOnly= false });
Response.SetCOOKIE(new HttpCOOKIE("user-name") { Value = data.Login, HttpOnly= false });

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void applyCOOKIEs() {
getCOOKIEs().values().stream().flatMap(Collection::stream)
.map(COOKIE -> new HttpCOOKIE(COOKIE.getName(), COOKIE.getValue()))
.forEach(this.jettyRequest::COOKIE);
}

代码示例来源:origin: org.springframework/spring-web

@Override
protected void applyCOOKIEs() {
getCOOKIEs().values().stream().flatMap(Collection::stream)
.map(COOKIE -> new HttpCOOKIE(COOKIE.getName(), COOKIE.getValue()))
.forEach(this.jettyRequest::COOKIE);
}

代码示例来源:origin: aa112901/remusic

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
String name = (String) in.readObject();
String value = (String) in.readObject();
clientCOOKIE = new HttpCOOKIE(name, value);
clientCOOKIE.setComment((String) in.readObject());
clientCOOKIE.setCommentURL((String) in.readObject());
clientCOOKIE.setDomain((String) in.readObject());
clientCOOKIE.setMaxAge(in.readLong());
clientCOOKIE.setPath((String) in.readObject());
clientCOOKIE.setPortlist((String) in.readObject());
clientCOOKIE.setVersion(in.readInt());
clientCOOKIE.setSecure(in.readBoolean());
clientCOOKIE.setDiscard(in.readBoolean());
}
}

代码示例来源:origin: cSploit/android

COOKIE = new HttpCOOKIE(COOKIEName, COOKIEValue);
} catch (IllegalArgumentException e){
Logger.error("Invalid COOKIE. name=" + COOKIEName + ":" + COOKIEValue);

代码示例来源:origin: robovm/robovm

HttpCOOKIE COOKIE = new HttpCOOKIE(name, value);
COOKIE.version = pre2965 ? 0 : 1;
COOKIEs.add(COOKIE);

代码示例来源:origin: stackoverflow.com

String name = (String) in.readObject();
String value = (String) in.readObject();
clientCOOKIE = new HttpCOOKIE(name, value);
clientCOOKIE.setComment((String) in.readObject());
clientCOOKIE.setCommentURL((String) in.readObject());

代码示例来源:origin: wiztools/rest-client

private List getCOOKIEsFromCOOKIEsNode(final Element node)
throws XMLException {
List out = new ArrayList<>();

for (int i = 0; i Element e = node.getChildElements().get(i);
if(!"COOKIE".equals(e.getQualifiedName())) {
throw new XMLException(" element should contain only elements");
}

HttpCOOKIE COOKIE = new HttpCOOKIE(e.getAttributeValue("name"),
e.getAttributeValue("value"));
final String COOKIEVerStr = e.getAttributeValue("version");
if(StringUtil.isNotEmpty(COOKIEVerStr)) {
COOKIE.setVersion(Integer.parseInt(COOKIEVerStr));
}
else {
COOKIE.setVersion(COOKIEVersion.DEFAULT_VERSION.getIntValue());
}
out.add(COOKIE);
}

return out;
}

代码示例来源:origin: yanzhenjie/NoHttp

/**
* Into {@link HttpCOOKIE}.
*
* @return {@link HttpCOOKIE}.
*/
public HttpCOOKIE toHttpCOOKIE() {
HttpCOOKIE COOKIE = new HttpCOOKIE(name, value);
COOKIE.setComment(comment);
COOKIE.setCommentURL(commentURL);
COOKIE.setDiscard(discard);
COOKIE.setDomain(domain);
if (expiry == -1L)
COOKIE.setMaxAge(-1L);
else
COOKIE.setMaxAge((expiry - System.currentTimeMillis()) / 1000L);
COOKIE.setPath(path);
COOKIE.setPortlist(portList);
COOKIE.setSecure(secure);
COOKIE.setVersion(version);
return COOKIE;
}

代码示例来源:origin: wiztools/rest-client

for(final String value: values) {
try {
HttpCOOKIE COOKIE = new HttpCOOKIE(key, value);
COOKIE.setVersion(jp_req_etc.getCOOKIEVersion().getIntValue());
request.addCOOKIE(COOKIE);

代码示例来源:origin: webbit/webbit

public StubHttpResponse COOKIE(String name, String value) {
return COOKIE(new HttpCOOKIE(name, value));
}

代码示例来源:origin: stackoverflow.com

public class SafariController : Controller
{
[HttpGet]
public ActionResult COOKIEFix()
{
Response.COOKIEs.Add(new HttpCOOKIE("safari_COOKIE_fix", "1"));
return Redirect(Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : "http://www.domain-a.com/");
}
}

代码示例来源:origin: webbit/webbit

private static List toHttpCOOKIE(Set nettyCOOKIEs) {
List result = new ArrayList();
for (COOKIE n : nettyCOOKIEs) {
HttpCOOKIE COOKIE = new HttpCOOKIE(n.getName(), n.getValue());
COOKIE.setSecure(n.isSecure());
COOKIE.setPath(n.getPath());
COOKIE.setDomain(n.getDomain());
// Unspecified max-age in Netty is Integer.MIN_VALUE, while it's -1 in java.net.HttpCOOKIE
long maxAge = n.getMaxAge() == Integer.MIN_VALUE ? -1 : n.getMaxAge();
COOKIE.setMaxAge(maxAge);
COOKIE.setDiscard(n.isDiscard());
COOKIE.setVersion(n.getVersion());
result.add(COOKIE);
}
return result;
}
}

代码示例来源:origin: stackoverflow.com

foreach (string key in Request.COOKIEs.AllKeys)
{
HttpCOOKIE COOKIE = new HttpCOOKIE(key);
COOKIE.Expires = DateTime.UtcNow.AddDays(-7);
Response.COOKIEs.Add(COOKIE);
}

代码示例来源:origin: org.apache.hadoop/hadoop-auth

private void setAuthCOOKIEValue(String value) {
HttpCOOKIE c = null;
if (value != null) {
c = new HttpCOOKIE(AUTH_COOKIE, value);
}
setAuthCOOKIE(c);
}
}

代码示例来源:origin: io.github.http-builder-ng/http-builder-ng-core

public void COOKIE(final String name, final String value, final Instant instant) {
final HttpCOOKIE COOKIE = new HttpCOOKIE(name, value);
COOKIE.setPath("/");
final Instant now = Instant.now();
if(instant != null && now.isBefore(instant)) {
COOKIE.setMaxAge(instant.getEpochSecond() - now.getEpochSecond());
}
getCOOKIEs().add(COOKIE);
}

代码示例来源:origin: org.codehaus.groovy.modules/http-builder-ng-core

public void COOKIE(final String name, final String value, final Instant instant) {
final HttpCOOKIE COOKIE = new HttpCOOKIE(name, value);
COOKIE.setPath("/");
final Instant now = Instant.now();
if(instant != null && now.isBefore(instant)) {
COOKIE.setMaxAge(instant.getEpochSecond() - now.getEpochSecond());
}

getCOOKIEs().add(COOKIE);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
protected void applyCOOKIEs() {
getCOOKIEs().values().stream().flatMap(Collection::stream)
.map(COOKIE -> new HttpCOOKIE(COOKIE.getName(), COOKIE.getValue()))
.forEach(this.jettyRequest::COOKIE);
}

代码示例来源:origin: stackoverflow.com

HttpCOOKIE COOKIE = new HttpCOOKIE("PHPSESSID", getPhpSessionID());
COOKIE.setPath("/");
COOKIE.setVersion(0);
COOKIE.setDomain("www.example.com");
((COOKIEManager)client.getCOOKIEHandler()).getCOOKIEStore().add(new URI("http://www.example.com"), COOKIE);

代码示例来源:origin: org.minijax/minijax-core

@Override
public String toString(final COOKIE COOKIE) {
final HttpCOOKIE httpCOOKIE = new HttpCOOKIE(COOKIE.getName(), COOKIE.getValue());
httpCOOKIE.setDomain(COOKIE.getDomain());
httpCOOKIE.setPath(COOKIE.getPath());
return httpCOOKIE.toString();
}
}

推荐阅读
author-avatar
lipei0927
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有