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


Java Cookie.setDomainAttributeSpecified方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.Cookie.setDomainAttributeSpecified方法的典型用法代碼示例。如果您正苦於以下問題:Java Cookie.setDomainAttributeSpecified方法的具體用法?Java Cookie.setDomainAttributeSpecified怎麽用?Java Cookie.setDomainAttributeSpecified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.Cookie的用法示例。


在下文中一共展示了Cookie.setDomainAttributeSpecified方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
 * Parse cookie domain attribute.
 */
public void parse(final Cookie cookie, String domain)
        throws MalformedCookieException {
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().equals("")) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    domain = domain.toLowerCase();
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute 
        // MAY NOT be an IP address of a host name
        domain = "." + domain;
    }
    cookie.setDomain(domain);
    cookie.setDomainAttributeSpecified(true);
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:29,代碼來源:RFC2965Spec.java

示例2: testSecondDomainLevelCookie

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
 * Tests if invalid second domain level cookie gets accepted in the
 * browser compatibility mode.
 */
public void testSecondDomainLevelCookie() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    cookiespec.validate("sourceforge.net", 80, "/", false, cookie);
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:13,代碼來源:TestCookieCompatibilitySpec.java

示例3: testSecondDomainLevelCookieMatch1

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testSecondDomainLevelCookieMatch1() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    assertTrue(cookiespec.match("sourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieCompatibilitySpec.java

示例4: testSecondDomainLevelCookieMatch2

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testSecondDomainLevelCookieMatch2() throws Exception {
    Cookie cookie = new Cookie("sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    assertTrue(cookiespec.match("www.sourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieCompatibilitySpec.java

示例5: testSecondDomainLevelCookieMatch3

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testSecondDomainLevelCookieMatch3() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
     cookie.setDomainAttributeSpecified(true);
     cookie.setPathAttributeSpecified(true);

     CookieSpec cookiespec = new CookieSpecBase();
     assertTrue(cookiespec.match("www.sourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieCompatibilitySpec.java

示例6: testInvalidSecondDomainLevelCookieMatch1

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testInvalidSecondDomainLevelCookieMatch1() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    assertFalse(cookiespec.match("antisourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieCompatibilitySpec.java

示例7: testInvalidSecondDomainLevelCookieMatch2

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testInvalidSecondDomainLevelCookieMatch2() throws Exception {
    Cookie cookie = new Cookie("sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    assertFalse(cookiespec.match("antisourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieCompatibilitySpec.java

示例8: testInvalidMatchDomain

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testInvalidMatchDomain() throws Exception {
    Cookie cookie = new Cookie("beta.gamma.com", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    cookiespec.validate("alpha.beta.gamma.com", 80, "/", false, cookie);
    assertTrue(cookiespec.match("alpha.beta.gamma.com", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:10,代碼來源:TestCookieCompatibilitySpec.java

示例9: testNullCookieValueFormatting

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
 * Tests if null cookie values are handled correctly.
 */
public void testNullCookieValueFormatting() {
    Cookie cookie = new Cookie(".whatever.com", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new CookieSpecBase();
    String s = cookiespec.formatCookie(cookie);
    assertEquals("name=", s);
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:13,代碼來源:TestCookieCompatibilitySpec.java

示例10: testSecondDomainLevelCookie

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
 * Tests if that invalid second domain level cookie gets 
 * rejected in the strict mode, but gets accepted in the
 * browser compatibility mode.
 */
public void testSecondDomainLevelCookie() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new RFC2109Spec();
    try {
        cookiespec.validate("sourceforge.net", 80, "/", false, cookie);
        fail("MalformedCookieException should have been thrown");
    } catch (MalformedCookieException e) {
        // Expected
    }
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:19,代碼來源:TestCookieRFC2109Spec.java

示例11: testSecondDomainLevelCookieMatch

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testSecondDomainLevelCookieMatch() throws Exception {
    Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new RFC2109Spec();
    assertFalse(cookiespec.match("sourceforge.net", 80, "/", false, cookie));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:9,代碼來源:TestCookieRFC2109Spec.java

示例12: testNullCookieValueFormatting

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
 * Tests if null cookie values are handled correctly.
 */
public void testNullCookieValueFormatting() {
    Cookie cookie = new Cookie(".whatever.com", "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new RFC2109Spec();
    String s = cookiespec.formatCookie(cookie);
    assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com", s);

    cookie.setVersion(1);
    s = cookiespec.formatCookie(cookie);
    assertEquals("$Version=\"1\"; name=\"\"; $Path=\"/\"; $Domain=\".whatever.com\"", s);
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:17,代碼來源:TestCookieRFC2109Spec.java

示例13: testCookieNullDomainNullPathFormatting

import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public void testCookieNullDomainNullPathFormatting() {
    Cookie cookie = new Cookie(null, "name", null, "/", null, false); 
    cookie.setDomainAttributeSpecified(true);
    cookie.setPathAttributeSpecified(true);

    CookieSpec cookiespec = new RFC2109Spec();
    String s = cookiespec.formatCookie(cookie);
    assertEquals("$Version=0; name=; $Path=/", s);

    cookie.setDomainAttributeSpecified(false);
    cookie.setPathAttributeSpecified(false);
    s = cookiespec.formatCookie(cookie);
    assertEquals("$Version=0; name=", s);
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:15,代碼來源:TestCookieRFC2109Spec.java


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