• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SM类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SM类属于org.apache.http.cookie包,在下文中一共展示了SM类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Override
public List<Cookie> parse(
        final Header header,
        CookieOrigin origin) throws MalformedCookieException {
    if (header == null) {
        throw new IllegalArgumentException("Header may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE2)) {
        throw new MalformedCookieException("Unrecognized cookie header '"
                + header.toString() + "'");
    }
    origin = adjustEffectiveHost(origin);
    HeaderElement[] elems = header.getElements();
    return createCookies(elems, origin);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:RFC2965Spec.java


示例2: formatCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookies may not be null");
    }
    if (cookies.isEmpty()) {
        throw new IllegalArgumentException("List of cookies may not be empty");
    }
    CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        String s = cookie.getValue();
        if (s != null) {
            buffer.append("=");
            buffer.append(s);
        }
    }
    List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:NetscapeDraftSpec.java


示例3: formatCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookies may not be null");
    }
    if (cookies.isEmpty()) {
        throw new IllegalArgumentException("List of cookies may not be empty");
    }
    CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        buffer.append("=");
        String s = cookie.getValue();
        if (s != null) {
            buffer.append(s);
        }
    }
    List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BrowserCompatSpec.java


示例4: formatCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notEmpty(cookies, "List of cookies");
    final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        final Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        final String s = cookie.getValue();
        if (s != null) {
            buffer.append("=");
            buffer.append(s);
        }
    }
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:22,代码来源:NetscapeDraftSpecHC4.java


示例5: formatCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Override
public List<Header> formatCookies(final List<Cookie> cookies) {
    Args.notEmpty(cookies, "List of cookies");
    final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        final Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        final String s = cookie.getValue();
        if (s != null) {
            buffer.append("=");
            buffer.append(s);
        }
    }
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:NetscapeDraftSpec.java


示例6: testParseCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testParseCookies() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(1, cookies.size());
    final Cookie cookie = cookies.get(0);
    Assert.assertEquals(0, cookie.getVersion());
    Assert.assertEquals("name1", cookie.getName());
    Assert.assertEquals("value1", cookie.getValue());
    Assert.assertEquals("localhost", cookie.getDomain());
    Assert.assertEquals("/", cookie.getPath());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestResponseProcessCookies.java


示例7: testNoCookieOrigin

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoCookieOrigin() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java


示例8: testNoCookieSpec

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoCookieSpec() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java


示例9: testNoCookieStore

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoCookieStore() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, null);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java


示例10: testSetCookie2OverrideSetCookie

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testSetCookie2OverrideSetCookie() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");
    response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(1, cookies.size());
    final Cookie cookie = cookies.get(0);
    Assert.assertEquals(1, cookie.getVersion());
    Assert.assertEquals("name1", cookie.getName());
    Assert.assertEquals("value2", cookie.getValue());
    Assert.assertEquals("localhost.local", cookie.getDomain());
    Assert.assertEquals("/", cookie.getPath());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:TestResponseProcessCookies.java


示例11: testInvalidHeader

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testInvalidHeader() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertTrue(cookies.isEmpty());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java


示例12: testCookieRejected

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testCookieRejected() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE2, "name=value; Domain=www.somedomain.com; Version=1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertTrue(cookies.isEmpty());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java


示例13: testCookiesForConnectRequest

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testCookiesForConnectRequest() throws Exception {
    final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");

    final HttpRoute route = new HttpRoute(this.target, null, false);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(0, headers1.length);
    final Header[] headers2 = request.getHeaders(SM.COOKIE2);
    Assert.assertNotNull(headers2);
    Assert.assertEquals(0, headers2.length);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestRequestAddCookies.java


示例14: testNoCookieStore

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoCookieStore() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");

    final HttpRoute route = new HttpRoute(this.target, null, false);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.COOKIE_STORE, null);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(0, headers1.length);
    final Header[] headers2 = request.getHeaders(SM.COOKIE2);
    Assert.assertNotNull(headers2);
    Assert.assertEquals(0, headers2.length);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestRequestAddCookies.java


示例15: testNoCookieSpecRegistry

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoCookieSpecRegistry() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");

    final HttpRoute route = new HttpRoute(this.target, null, false);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, null);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(0, headers1.length);
    final Header[] headers2 = request.getHeaders(SM.COOKIE2);
    Assert.assertNotNull(headers2);
    Assert.assertEquals(0, headers2.length);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestRequestAddCookies.java


示例16: testNoTargetHost

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoTargetHost() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");

    final HttpRoute route = new HttpRoute(this.target, null, false);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, null);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(0, headers1.length);
    final Header[] headers2 = request.getHeaders(SM.COOKIE2);
    Assert.assertNotNull(headers2);
    Assert.assertEquals(0, headers2.length);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestRequestAddCookies.java


示例17: testNoHttpConnection

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testNoHttpConnection() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpCoreContext.HTTP_CONNECTION, null);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(0, headers1.length);
    final Header[] headers2 = request.getHeaders(SM.COOKIE2);
    Assert.assertNotNull(headers2);
    Assert.assertEquals(0, headers2.length);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:TestRequestAddCookies.java


示例18: testAddCookiesUsingExplicitCookieSpec

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Test
public void testAddCookiesUsingExplicitCookieSpec() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");
    final RequestConfig config = RequestConfig.custom()
        .setCookieSpec(CookieSpecs.NETSCAPE).build();
    final HttpRoute route = new HttpRoute(this.target, null, false);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

    final HttpRequestInterceptor interceptor = new RequestAddCookies();
    interceptor.process(request, context);

    final CookieSpec cookieSpec = context.getCookieSpec();
    Assert.assertTrue(cookieSpec instanceof NetscapeDraftSpec);

    final Header[] headers1 = request.getHeaders(SM.COOKIE);
    Assert.assertNotNull(headers1);
    Assert.assertEquals(1, headers1.length);
    Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:TestRequestAddCookies.java


示例19: parseCookies

import org.apache.http.cookie.SM; //导入依赖的package包/类
private List<Cookie> parseCookies(String url, String cookieHeader) {
    CookieOrigin origin = getOrigin(url);
    BasicHeader header = new BasicHeader(SM.SET_COOKIE, cookieHeader);
    int attrIndex = 0;
    do {
      try {
        CookieSpec cookieSpec = createSpec();
        return cookieSpec.parse(header, origin);
      } catch (MalformedCookieException e) {
        int indexOfAttrTitle = cookieHeader.indexOf(COOKIE_ATTRS_NOT_STRICT[attrIndex]);
        if (indexOfAttrTitle != -1) {
          cookieHeader = cookieHeader.substring(0,indexOfAttrTitle);
          header = new BasicHeader(SM.SET_COOKIE, cookieHeader);
        }
        attrIndex++;
      }
    } while (attrIndex <= COOKIE_ATTRS_NOT_STRICT.length);
    return emtpyCookieList;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:20,代码来源:ShadowCookieManager.java


示例20: parse

import org.apache.http.cookie.SM; //导入依赖的package包/类
@Override
public List<Cookie> parse(
        final Header header, 
        CookieOrigin origin) throws MalformedCookieException {
    if (header == null) {
        throw new IllegalArgumentException("Header may not be null");
    }
    if (origin == null) {
        throw new IllegalArgumentException("Cookie origin may not be null");
    }
    if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE2)) {
        throw new MalformedCookieException("Unrecognized cookie header '"
                + header.toString() + "'");
    }
    origin = adjustEffectiveHost(origin);
    HeaderElement[] elems = header.getElements();
    return createCookies(elems, origin);
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:19,代码来源:RFC2965Spec.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProjectLibraryTable类代码示例发布时间:2022-05-22
下一篇:
Java ODataHttpHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap