當前位置: 首頁>>代碼示例>>Java>>正文


Java Cookie.getVersion方法代碼示例

本文整理匯總了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();
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:28,代碼來源:RFC2109Spec.java

示例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();
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:21,代碼來源:RFC2109Spec.java


注:本文中的org.apache.commons.httpclient.Cookie.getVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。