本文整理了Java中org.apache.http.cookie.Cookie.getPath()
方法的一些代码示例,展示了Cookie.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.getPath()
方法的具体详情如下:
包路径:org.apache.http.cookie.Cookie
类名称:Cookie
方法名:getPath
[英]Returns the path attribute of the cookie
[中]返回cookie的路径属性
代码示例来源:origin: robovm/robovm
private String normalizePath(final Cookie cookie) {
String path = cookie.getPath();
if (path == null) {
path = "/";
}
if (!path.endsWith("/")) {
path = path + '/';
}
return path;
}
代码示例来源:origin: internetarchive/heritrix3
/**
* Returns a string that uniquely identifies the cookie, The format The
* format of the key is {@code "normalizedDomain;name;path"}. Adapted from
* {@link CookieIdentityComparator#compare(Cookie, Cookie)}.
*/
protected String sortableKey(Cookie cookie) {
String normalizedDomain = normalizeHost(cookie.getDomain());
// use ";" as delimiter since it is the delimiter in the cookie header,
// so presumably can't appear in any of these values
StringBuilder buf = new StringBuilder(normalizedDomain);
buf.append(";").append(cookie.getName());
buf.append(";").append(cookie.getPath() != null ? cookie.getPath() : "/");
return buf.toString();
}
代码示例来源:origin: robovm/robovm
public boolean match(final Cookie cookie, final CookieOrigin origin) {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
String targetpath = origin.getPath();
String topmostPath = cookie.getPath();
if (topmostPath == null) {
topmostPath = "/";
}
if (topmostPath.length() > 1 && topmostPath.endsWith("/")) {
topmostPath = topmostPath.substring(0, topmostPath.length() - 1);
}
boolean match = targetpath.startsWith (topmostPath);
// if there is a match and these values are not exactly the same we have
// to make sure we're not matcing "/foobar" and "/foo"
if (match && targetpath.length() != topmostPath.length()) {
if (!topmostPath.endsWith("/")) {
match = (targetpath.charAt(topmostPath.length()) == '/');
}
}
return match;
}
代码示例来源:origin: robovm/robovm
/**
* Don't log the cookie's value; that's potentially sensitive information.
*/
private String cookieToString(Cookie cookie) {
return cookie.getClass().getSimpleName()
+ "[version=" + cookie.getVersion()
+ ",name=" + cookie.getName()
+ ",domain=" + cookie.getDomain()
+ ",path=" + cookie.getPath()
+ ",expiry=" + cookie.getExpiryDate()
+ "]";
}
// END android-added
代码示例来源:origin: robovm/robovm
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (!match(cookie, origin)) {
throw new MalformedCookieException(
"Illegal path attribute \"" + cookie.getPath()
+ "\". Path of origin: \"" + origin.getPath() + "\"");
}
}
代码示例来源:origin: internetarchive/heritrix3
line.append(cookie.getPath() != null ? cookie.getPath() : "/");
line.append(tab);
line.append(cookie.isSecure() ? "TRUE" : "FALSE");
代码示例来源: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: MobiVM/robovm
private String normalizePath(final Cookie cookie) {
String path = cookie.getPath();
if (path == null) {
path = "/";
}
if (!path.endsWith("/")) {
path = path + '/';
}
return path;
}
代码示例来源:origin: com.bugvm/bugvm-rt
private String normalizePath(final Cookie cookie) {
String path = cookie.getPath();
if (path == null) {
path = "/";
}
if (!path.endsWith("/")) {
path = path + '/';
}
return path;
}
代码示例来源:origin: ibinti/bugvm
private String normalizePath(final Cookie cookie) {
String path = cookie.getPath();
if (path == null) {
path = "/";
}
if (!path.endsWith("/")) {
path = path + '/';
}
return path;
}
代码示例来源:origin: com.hynnet/httpclient
private String normalizePath(final Cookie cookie) {
String path = cookie.getPath();
if (path == null) {
path = "/";
}
if (!path.endsWith("/")) {
path = path + '/';
}
return path;
}
代码示例来源:origin: org.doctester/doctester-core
private void printCookie(Cookie cookie) {
htmlDocument.add("Name: " + cookie.getName() + "<br/>");
htmlDocument.add("Path: " + cookie.getPath() + "<br/>");
htmlDocument.add("Domain: " + cookie.getDomain() + "<br/>");
htmlDocument.add("Value: " + cookie.getValue() + "<br/>");
}
代码示例来源:origin: adolfAn/FBReader_AS
Key(Cookie c) {
Domain = c.getDomain();
Path = c.getPath();
Name = c.getName();
}
代码示例来源:origin: grzegorznittner/chanu
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeObject(cookie.getName());
out.writeObject(cookie.getValue());
out.writeObject(cookie.getComment());
out.writeObject(cookie.getDomain());
out.writeObject(cookie.getExpiryDate());
out.writeObject(cookie.getPath());
out.writeInt(cookie.getVersion());
out.writeBoolean(cookie.isSecure());
}
代码示例来源:origin: yiwent/Mobike
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeObject(cookie.getName());
out.writeObject(cookie.getValue());
out.writeObject(cookie.getComment());
out.writeObject(cookie.getDomain());
out.writeObject(cookie.getExpiryDate());
out.writeObject(cookie.getPath());
out.writeInt(cookie.getVersion());
out.writeBoolean(cookie.isSecure());
}
代码示例来源:origin: MobiVM/robovm
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (!match(cookie, origin)) {
throw new MalformedCookieException(
"Illegal path attribute \"" + cookie.getPath()
+ "\". Path of origin: \"" + origin.getPath() + "\"");
}
}
代码示例来源:origin: ibinti/bugvm
@Override
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (!match(cookie, origin)) {
throw new CookieRestrictionViolationException(
"Illegal 'path' attribute \"" + cookie.getPath()
+ "\". Path of origin: \"" + origin.getPath() + "\"");
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (!match(cookie, origin)) {
throw new CookieRestrictionViolationException(
"Illegal path attribute \"" + cookie.getPath()
+ "\". Path of origin: \"" + origin.getPath() + "\"");
}
}
代码示例来源:origin: ibinti/bugvm
@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
return pathMatch(origin.getPath(), cookie.getPath());
}
代码示例来源:origin: com.bugvm/bugvm-rt
@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
return pathMatch(origin.getPath(), cookie.getPath());
}
内容来源于网络,如有侵权,请联系作者删除!