本文整理匯總了Java中org.apache.commons.httpclient.Cookie.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Cookie.getVersion方法的具體用法?Java Cookie.getVersion怎麽用?Java Cookie.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.Cookie
的用法示例。
在下文中一共展示了Cookie.getVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: formatCookies
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
* Create a RFC 2109 compliant <tt>"Cookie"</tt> header value containing all
* {@link Cookie}s in <i>cookies</i> suitable for sending in a <tt>"Cookie"
* </tt> header
* @param cookies an array of {@link Cookie}s to be formatted
* @return a string suitable for sending in a Cookie header.
*/
public String formatCookies(Cookie[] cookies) {
LOG.trace("enter RFC2109Spec.formatCookieHeader(Cookie[])");
int version = Integer.MAX_VALUE;
// Pick the lowerest common denominator
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
if (cookie.getVersion() < version) {
version = cookie.getVersion();
}
}
final StringBuffer buffer = new StringBuffer();
formatParam(buffer,
new NameValuePair("$Version", Integer.toString(version)),
version);
for (int i = 0; i < cookies.length; i++) {
buffer.append("; ");
formatCookieAsVer(buffer, cookies[i], version);
}
return buffer.toString();
}
示例2: formatCookie
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
* Return a string suitable for sending in a <tt>"Cookie"</tt> header as
* defined in RFC 2109
* @param cookie a {@link Cookie} to be formatted as string
* @return a string suitable for sending in a <tt>"Cookie"</tt> header.
*/
public String formatCookie(Cookie cookie) {
LOG.trace("enter RFC2109Spec.formatCookie(Cookie)");
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
int version = cookie.getVersion();
StringBuffer buffer = new StringBuffer();
formatParam(buffer,
new NameValuePair("$Version", Integer.toString(version)),
version);
buffer.append("; ");
formatCookieAsVer(buffer, cookie, version);
return buffer.toString();
}