当前位置: 首页>>代码示例>>Java>>正文


Java CookieAttributeHandler.parse方法代码示例

本文整理汇总了Java中org.apache.http.cookie.CookieAttributeHandler.parse方法的典型用法代码示例。如果您正苦于以下问题:Java CookieAttributeHandler.parse方法的具体用法?Java CookieAttributeHandler.parse怎么用?Java CookieAttributeHandler.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.cookie.CookieAttributeHandler的用法示例。


在下文中一共展示了CookieAttributeHandler.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testParseExpiryFunnyYear

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testParseExpiryFunnyYear() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new LaxExpiresHandler();
    h.parse(cookie, "23:59:59; 1-Apr-2008blah");

    final Date expiryDate = cookie.getExpiryDate();
    Assert.assertNotNull(expiryDate);
    final Calendar c = Calendar.getInstance();
    c.setTimeZone(LaxExpiresHandler.UTC);
    c.setTime(expiryDate);
    Assert.assertEquals(2008, c.get(Calendar.YEAR));
    Assert.assertEquals(Calendar.APRIL, c.get(Calendar.MONTH));
    Assert.assertEquals(1, c.get(Calendar.DAY_OF_MONTH));
    Assert.assertEquals(23, c.get(Calendar.HOUR_OF_DAY));
    Assert.assertEquals(59, c.get(Calendar.MINUTE));
    Assert.assertEquals(59, c.get(Calendar.SECOND));
    Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java

示例2: testParseExpiryFunnyMonth

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testParseExpiryFunnyMonth() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new LaxExpiresHandler();
    h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008");

    final Date expiryDate = cookie.getExpiryDate();
    Assert.assertNotNull(expiryDate);
    final Calendar c = Calendar.getInstance();
    c.setTimeZone(LaxExpiresHandler.UTC);
    c.setTime(expiryDate);
    Assert.assertEquals(2008, c.get(Calendar.YEAR));
    Assert.assertEquals(Calendar.APRIL, c.get(Calendar.MONTH));
    Assert.assertEquals(1, c.get(Calendar.DAY_OF_MONTH));
    Assert.assertEquals(23, c.get(Calendar.HOUR_OF_DAY));
    Assert.assertEquals(59, c.get(Calendar.MINUTE));
    Assert.assertEquals(59, c.get(Calendar.SECOND));
    Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java

示例3: parse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
            throws MalformedCookieException {
    List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
    for (HeaderElement headerelement : elems) {
        String name = headerelement.getName();
        String value = headerelement.getValue();
        if (name == null || name.length() == 0) {
            throw new MalformedCookieException("Cookie name may not be empty");
        }

        BasicClientCookie cookie = new BasicClientCookie(name, value);
        cookie.setPath(getDefaultPath(origin));
        cookie.setDomain(getDefaultDomain(origin));

        // cycle through the parameters
        NameValuePair[] attribs = headerelement.getParameters();
        for (int j = attribs.length - 1; j >= 0; j--) {
            NameValuePair attrib = attribs[j];
            String s = attrib.getName().toLowerCase(Locale.ENGLISH);

            cookie.setAttribute(s, attrib.getValue());

            CookieAttributeHandler handler = findAttribHandler(s);
            if (handler != null) {
                handler.parse(cookie, attrib.getValue());
            }
        }
        cookies.add(cookie);
    }
    return cookies;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:CookieSpecBase.java

示例4: testBasicDomainParse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicDomainParse() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new BasicDomainHandler();
    h.parse(cookie, "www.somedomain.com");
    Assert.assertEquals("www.somedomain.com", cookie.getDomain());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestBasicCookieAttribHandlers.java

示例5: testBasicMaxAgeParse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicMaxAgeParse() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new BasicMaxAgeHandler();
    h.parse(cookie, "2000");
    Assert.assertNotNull(cookie.getExpiryDate());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestBasicCookieAttribHandlers.java

示例6: testBasicCommentInvalidInput

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicCommentInvalidInput() throws Exception {
    final CookieAttributeHandler h = new BasicCommentHandler();
    try {
        h.parse(null, null);
        Assert.fail("IllegalArgumentException must have been thrown");
    } catch (final IllegalArgumentException ex) {
        // expected
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:TestBasicCookieAttribHandlers.java

示例7: testBasicSecureParse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicSecureParse() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new BasicSecureHandler();
    h.parse(cookie, "whatever");
    Assert.assertTrue(cookie.isSecure());
    h.parse(cookie, null);
    Assert.assertTrue(cookie.isSecure());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestBasicCookieAttribHandlers.java

示例8: testRFC2109VersionParse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testRFC2109VersionParse() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new RFC2109VersionHandler();
    h.parse(cookie, "12");
    Assert.assertEquals(12, cookie.getVersion());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestRFC2109CookieAttribHandlers.java

示例9: testParseMaxZero

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testParseMaxZero() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new LaxMaxAgeHandler();
    h.parse(cookie, "0000");
    Assert.assertNotNull(cookie.getExpiryDate());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestLaxCookieAttribHandlers.java

示例10: testBasicMaxAgeParseEmpty

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicMaxAgeParseEmpty() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new LaxMaxAgeHandler();
    h.parse(cookie, "  ");
    Assert.assertNull(cookie.getExpiryDate());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestLaxCookieAttribHandlers.java

示例11: testBasicMaxAgeParseInvalid

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicMaxAgeParseInvalid() throws Exception {
    final BasicClientCookie cookie = new BasicClientCookie("name", "value");
    final CookieAttributeHandler h = new LaxMaxAgeHandler();
    h.parse(cookie, "garbage");
    Assert.assertNull(cookie.getExpiryDate());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestLaxCookieAttribHandlers.java

示例12: testBasicMaxAgeInvalidInput

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
@Test
public void testBasicMaxAgeInvalidInput() throws Exception {
    final CookieAttributeHandler h = new LaxMaxAgeHandler();
    try {
        h.parse(null, "stuff");
        Assert.fail("IllegalArgumentException must have been thrown");
    } catch (final IllegalArgumentException ex) {
        // expected
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:TestLaxCookieAttribHandlers.java

示例13: parse

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
            throws MalformedCookieException {
    final List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
    for (final HeaderElement headerelement : elems) {
        final String name = headerelement.getName();
        final String value = headerelement.getValue();
        if (name == null || name.length() == 0) {
            throw new MalformedCookieException("Cookie name may not be empty");
        }

        final BasicClientCookieHC4 cookie = new BasicClientCookieHC4(name, value);
        cookie.setPath(getDefaultPath(origin));
        cookie.setDomain(getDefaultDomain(origin));

        // cycle through the parameters
        final NameValuePair[] attribs = headerelement.getParameters();
        for (int j = attribs.length - 1; j >= 0; j--) {
            final NameValuePair attrib = attribs[j];
            final String s = attrib.getName().toLowerCase(Locale.ENGLISH);

            cookie.setAttribute(s, attrib.getValue());

            final CookieAttributeHandler handler = findAttribHandler(s);
            if (handler != null) {
                handler.parse(cookie, attrib.getValue());
            }
        }
        cookies.add(cookie);
    }
    return cookies;
}
 
开发者ID:SxdsF,项目名称:Visit,代码行数:32,代码来源:CookieSpecBaseHC4.java

示例14: createCookies

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
private List<Cookie> createCookies(
        final HeaderElement[] elems,
        final CookieOrigin origin) throws MalformedCookieException {
    List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
    for (HeaderElement headerelement : elems) {
        String name = headerelement.getName();
        String value = headerelement.getValue();
        if (name == null || name.length() == 0) {
            throw new MalformedCookieException("Cookie name may not be empty");
        }

        BasicClientCookie2 cookie = new BasicClientCookie2(name, value);
        cookie.setPath(getDefaultPath(origin));
        cookie.setDomain(getDefaultDomain(origin));
        cookie.setPorts(new int [] { origin.getPort() });
        // cycle through the parameters
        NameValuePair[] attribs = headerelement.getParameters();

        // Eliminate duplicate attributes. The first occurrence takes precedence
        // See RFC2965: 3.2  Origin Server Role
        Map<String, NameValuePair> attribmap =
                new HashMap<String, NameValuePair>(attribs.length);
        for (int j = attribs.length - 1; j >= 0; j--) {
            NameValuePair param = attribs[j];
            attribmap.put(param.getName().toLowerCase(Locale.ENGLISH), param);
        }
        for (Map.Entry<String, NameValuePair> entry : attribmap.entrySet()) {
            NameValuePair attrib = entry.getValue();
            String s = attrib.getName().toLowerCase(Locale.ENGLISH);

            cookie.setAttribute(s, attrib.getValue());

            CookieAttributeHandler handler = findAttribHandler(s);
            if (handler != null) {
                handler.parse(cookie, attrib.getValue());
            }
        }
        cookies.add(cookie);
    }
    return cookies;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:RFC2965Spec.java

示例15: createCookies

import org.apache.http.cookie.CookieAttributeHandler; //导入方法依赖的package包/类
private List<Cookie> createCookies(
        final HeaderElement[] elems,
        final CookieOrigin origin) throws MalformedCookieException {
    final List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
    for (final HeaderElement headerelement : elems) {
        final String name = headerelement.getName();
        final String value = headerelement.getValue();
        if (name == null || name.length() == 0) {
            throw new MalformedCookieException("Cookie name may not be empty");
        }

        final BasicClientCookie2HC4 cookie = new BasicClientCookie2HC4(name, value);
        cookie.setPath(getDefaultPath(origin));
        cookie.setDomain(getDefaultDomain(origin));
        cookie.setPorts(new int [] { origin.getPort() });
        // cycle through the parameters
        final NameValuePair[] attribs = headerelement.getParameters();

        // Eliminate duplicate attributes. The first occurrence takes precedence
        // See RFC2965: 3.2  Origin Server Role
        final Map<String, NameValuePair> attribmap =
                new HashMap<String, NameValuePair>(attribs.length);
        for (int j = attribs.length - 1; j >= 0; j--) {
            final NameValuePair param = attribs[j];
            attribmap.put(param.getName().toLowerCase(Locale.ENGLISH), param);
        }
        for (final Map.Entry<String, NameValuePair> entry : attribmap.entrySet()) {
            final NameValuePair attrib = entry.getValue();
            final String s = attrib.getName().toLowerCase(Locale.ENGLISH);

            cookie.setAttribute(s, attrib.getValue());

            final CookieAttributeHandler handler = findAttribHandler(s);
            if (handler != null) {
                handler.parse(cookie, attrib.getValue());
            }
        }
        cookies.add(cookie);
    }
    return cookies;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:42,代码来源:RFC2965SpecHC4.java


注:本文中的org.apache.http.cookie.CookieAttributeHandler.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。