本文整理了Java中io.netty.handler.codec.http.cookie.Cookie.path()
方法的一些代码示例,展示了Cookie.path()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.path()
方法的具体详情如下:
包路径:io.netty.handler.codec.http.cookie.Cookie
类名称:Cookie
方法名:path
[英]Returns the path of this Cookie.
[中]返回此Cookie的路径。
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public String getPath() {
return nettyCookie.path();
}
代码示例来源:origin: wildfly/wildfly
@Override
public int compare(Cookie c1, Cookie c2) {
String path1 = c1.path();
String path2 = c2.path();
// Cookies with unspecified path default to the path of the request. We don't
// know the request path here, but we assume that the length of an unspecified
// path is longer than any specified path (i.e. pathless cookies come first),
// because setting cookies with a path longer than the request path is of
// limited use.
int len1 = path1 == null ? Integer.MAX_VALUE : path1.length();
int len2 = path2 == null ? Integer.MAX_VALUE : path2.length();
int diff = len2 - len1;
if (diff != 0) {
return diff;
}
// Rely on Java's sort stability to retain creation order in cases where
// cookies have same path length.
return -1;
}
};
代码示例来源:origin: jooby-project/jooby
private org.jooby.Cookie cookie(final Cookie c) {
org.jooby.Cookie.Definition cookie = new org.jooby.Cookie.Definition(c.name(), c.value());
Optional.ofNullable(c.domain()).ifPresent(cookie::domain);
Optional.ofNullable(c.path()).ifPresent(cookie::path);
return cookie.toCookie();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
this.response.cookies().values().stream().flatMap(Collection::stream)
.forEach(cookie ->
result.add(cookie.name(), ResponseCookie.from(cookie.name(), cookie.value())
.domain(cookie.domain())
.path(cookie.path())
.maxAge(cookie.maxAge())
.secure(cookie.isSecure())
.httpOnly(cookie.isHttpOnly())
.build()));
return CollectionUtils.unmodifiableMultiValueMap(result);
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* @param path The path
* @param nettyHeaders The Netty HTTP headers
* @param conversionService The conversion service
*/
public NettyCookies(String path, HttpHeaders nettyHeaders, ConversionService conversionService) {
this.conversionService = conversionService;
String value = nettyHeaders.get(HttpHeaderNames.COOKIE);
if (value != null) {
cookies = new LinkedHashMap<>();
Set<io.netty.handler.codec.http.cookie.Cookie> nettyCookies = ServerCookieDecoder.LAX.decode(value);
for (io.netty.handler.codec.http.cookie.Cookie nettyCookie : nettyCookies) {
String cookiePath = nettyCookie.path();
if (cookiePath != null) {
if (path.startsWith(cookiePath)) {
cookies.put(nettyCookie.name(), new NettyCookie(nettyCookie));
}
} else {
cookies.put(nettyCookie.name(), new NettyCookie(nettyCookie));
}
}
} else {
cookies = Collections.emptyMap();
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Cookie)) {
return false;
}
Cookie that = (Cookie) o;
if (!name().equals(that.name())) {
return false;
}
if (path() == null) {
if (that.path() != null) {
return false;
}
} else if (that.path() == null) {
return false;
} else if (!path().equals(that.path())) {
return false;
}
if (domain() == null) {
if (that.domain() != null) {
return false;
}
} else {
return domain().equalsIgnoreCase(that.domain());
}
return true;
}
代码示例来源:origin: wildfly/wildfly
@Override
public int compareTo(Cookie c) {
int v = name().compareTo(c.name());
if (v != 0) {
return v;
}
if (path() == null) {
if (c.path() != null) {
return -1;
}
} else if (c.path() == null) {
return 1;
} else {
v = path().compareTo(c.path());
if (v != 0) {
return v;
}
}
if (domain() == null) {
if (c.domain() != null) {
return -1;
}
} else if (c.domain() == null) {
return 1;
} else {
v = domain().compareToIgnoreCase(c.domain());
return v;
}
return 0;
}
代码示例来源:origin: AsyncHttpClient/async-http-client
private void add(String requestDomain, String requestPath, Cookie cookie) {
AbstractMap.SimpleEntry<String, Boolean> pair = cookieDomain(cookie.domain(), requestDomain);
String keyDomain = pair.getKey();
boolean hostOnly = pair.getValue();
String keyPath = cookiePath(cookie.path(), requestPath);
CookieKey key = new CookieKey(cookie.name().toLowerCase(), keyDomain, keyPath);
if (hasCookieExpired(cookie, 0))
cookieJar.remove(key);
else
cookieJar.put(key, new StoredCookie(cookie, hostOnly, cookie.maxAge() != Cookie.UNDEFINED_MAX_AGE));
}
代码示例来源:origin: org.springframework/spring-web
@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
this.response.cookies().values().stream().flatMap(Collection::stream)
.forEach(cookie ->
result.add(cookie.name(), ResponseCookie.from(cookie.name(), cookie.value())
.domain(cookie.domain())
.path(cookie.path())
.maxAge(cookie.maxAge())
.secure(cookie.isSecure())
.httpOnly(cookie.isHttpOnly())
.build()));
return CollectionUtils.unmodifiableMultiValueMap(result);
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
org.apache.http.HttpResponse response = helper.getResponse(root());
String value = response.getFirstHeader(HttpHeaders.SET_COOKIE).getValue();
Cookie decodeCookie = ClientCookieDecoder.STRICT.decode(value);
assertThat(decodeCookie.path(), is("/"));
}
});
代码示例来源:origin: line/armeria
private MultiValueMap<String, ResponseCookie> initCookies() {
final MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>();
headers.getAll(HttpHeaderNames.SET_COOKIE)
.stream()
.map(ClientCookieDecoder.LAX::decode)
.forEach(c -> cookies.add(c.name(), ResponseCookie.from(c.name(), c.value())
.maxAge(c.maxAge())
.domain(c.domain())
.path(c.path())
.secure(c.isSecure())
.httpOnly(c.isHttpOnly())
.build()));
return cookies;
}
代码示例来源:origin: dreamhead/moco
@Test
public void should_set_and_recognize_cookie_with_path() throws IOException {
runWithConfiguration("cookie.json");
Cookie decodeCookie = getCookie("/cookie-with-path");
assertThat(decodeCookie.name(), is("login"));
assertThat(decodeCookie.value(), is("true"));
assertThat(decodeCookie.path(), is("/"));
}
代码示例来源:origin: wildfly/wildfly
if (cookie.path() != null) {
add(buf, CookieHeaderNames.PATH, cookie.path());
代码示例来源:origin: lets-blade/blade
/**
* Parse netty cookie to {@link Cookie}.
*
* @param nettyCookie netty raw cookie instance
*/
private void parseCookie(io.netty.handler.codec.http.cookie.Cookie nettyCookie) {
var cookie = new Cookie();
cookie.name(nettyCookie.name());
cookie.value(nettyCookie.value());
cookie.httpOnly(nettyCookie.isHttpOnly());
cookie.path(nettyCookie.path());
cookie.domain(nettyCookie.domain());
cookie.maxAge(nettyCookie.maxAge());
this.cookies.put(cookie.name(), cookie);
}
代码示例来源:origin: lets-blade/blade
/**
* Parse netty cookie to {@link Cookie}.
*
* @param nettyCookie netty raw cookie instance
*/
private void parseCookie(io.netty.handler.codec.http.cookie.Cookie nettyCookie) {
var cookie = new Cookie();
cookie.name(nettyCookie.name());
cookie.value(nettyCookie.value());
cookie.httpOnly(nettyCookie.isHttpOnly());
cookie.path(nettyCookie.path());
cookie.domain(nettyCookie.domain());
cookie.maxAge(nettyCookie.maxAge());
this.cookies.put(cookie.name(), cookie);
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
harCookie.setPath(cookie.path());
harCookie.setSecure(cookie.isSecure());
if (cookie.maxAge() > 0) {
代码示例来源:origin: vert-x3/vertx-web
@Override
public String getPath() {
return nettyCookie.path();
}
代码示例来源:origin: line/armeria
assertThat(setCookie.value()).isEqualTo("1");
assertThat(setCookie.domain()).isEqualTo("http://localhost");
assertThat(setCookie.path()).isEqualTo("/");
assertThat(setCookie.maxAge()).isEqualTo(Duration.ofSeconds(60).getSeconds());
assertThat(setCookie.isSecure()).isTrue();
代码示例来源:origin: io.vertx/vertx-web
@Override
public String getPath() {
return nettyCookie.path();
}
代码示例来源:origin: HotelsDotCom/styx
private static ResponseCookie convert(Cookie cookie) {
String value = cookie.wrap() ? quote(cookie.value()) : cookie.value();
return responseCookie(cookie.name(), value)
.domain(cookie.domain())
.path(cookie.path())
.maxAge(cookie.maxAge())
.httpOnly(cookie.isHttpOnly())
.secure(cookie.isSecure())
.build();
}
内容来源于网络,如有侵权,请联系作者删除!