io.netty.handler.codec.http.cookie.Cookie.domain()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中io.netty.handler.codec.http.cookie.Cookie.domain()方法的一些代码示例,展示了Cookie.domain()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.domain()方法的具体详情如下:
包路径:io.netty.handler.codec.http.cookie.Cookie
类名称:Cookie
方法名:domain

Cookie.domain介绍

[英]Returns the domain of this Cookie.
[中]返回此Cookie的域。

代码示例

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public String getDomain() {
  return nettyCookie.domain();
}

代码示例来源:origin: jooby-project/jooby

private org.jooby.Cookie cookie(final Cookie c) {
 org.jooby.Cookie.Definition cookie = new org.jooby.Cookie.Definition(c.name(), c.value());
 Optional.ofNullable(c.domain()).ifPresent(cookie::domain);
 Optional.ofNullable(c.path()).ifPresent(cookie::path);
 return cookie.toCookie();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
  MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
  this.response.cookies().values().stream().flatMap(Collection::stream)
      .forEach(cookie ->
        result.add(cookie.name(), ResponseCookie.from(cookie.name(), cookie.value())
            .domain(cookie.domain())
            .path(cookie.path())
            .maxAge(cookie.maxAge())
            .secure(cookie.isSecure())
            .httpOnly(cookie.isHttpOnly())
            .build()));
  return CollectionUtils.unmodifiableMultiValueMap(result);
}

代码示例来源:origin: AsyncHttpClient/async-http-client

private void add(String requestDomain, String requestPath, Cookie cookie) {
 AbstractMap.SimpleEntry<String, Boolean> pair = cookieDomain(cookie.domain(), requestDomain);
 String keyDomain = pair.getKey();
 boolean hostOnly = pair.getValue();
 String keyPath = cookiePath(cookie.path(), requestPath);
 CookieKey key = new CookieKey(cookie.name().toLowerCase(), keyDomain, keyPath);
 if (hasCookieExpired(cookie, 0))
  cookieJar.remove(key);
 else
  cookieJar.put(key, new StoredCookie(cookie, hostOnly, cookie.maxAge() != Cookie.UNDEFINED_MAX_AGE));
}

代码示例来源:origin: wildfly/wildfly

@Override
public int compareTo(Cookie c) {
  int v = name().compareTo(c.name());
  if (v != 0) {
    return v;
  }
  if (path() == null) {
    if (c.path() != null) {
      return -1;
    }
  } else if (c.path() == null) {
    return 1;
  } else {
    v = path().compareTo(c.path());
    if (v != 0) {
      return v;
    }
  }
  if (domain() == null) {
    if (c.domain() != null) {
      return -1;
    }
  } else if (c.domain() == null) {
    return 1;
  } else {
    v = domain().compareToIgnoreCase(c.domain());
    return v;
  }
  return 0;
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (!(o instanceof Cookie)) {
    return false;
  }
  Cookie that = (Cookie) o;
  if (!name().equals(that.name())) {
    return false;
  }
  if (path() == null) {
    if (that.path() != null) {
      return false;
    }
  } else if (that.path() == null) {
    return false;
  } else if (!path().equals(that.path())) {
    return false;
  }
  if (domain() == null) {
    if (that.domain() != null) {
      return false;
    }
  } else {
    return domain().equalsIgnoreCase(that.domain());
  }
  return true;
}

代码示例来源:origin: org.springframework/spring-web

@Override
public MultiValueMap<String, ResponseCookie> getCookies() {
  MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
  this.response.cookies().values().stream().flatMap(Collection::stream)
      .forEach(cookie ->
        result.add(cookie.name(), ResponseCookie.from(cookie.name(), cookie.value())
            .domain(cookie.domain())
            .path(cookie.path())
            .maxAge(cookie.maxAge())
            .secure(cookie.isSecure())
            .httpOnly(cookie.isHttpOnly())
            .build()));
  return CollectionUtils.unmodifiableMultiValueMap(result);
}

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws IOException {
    org.apache.http.HttpResponse response = helper.getResponse(root());
    String value = response.getFirstHeader(HttpHeaders.SET_COOKIE).getValue();
    Cookie decodeCookie = ClientCookieDecoder.STRICT.decode(value);
    assertThat(decodeCookie.domain(), is("localhost"));
  }
});

代码示例来源:origin: line/armeria

private MultiValueMap<String, ResponseCookie> initCookies() {
  final MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>();
  headers.getAll(HttpHeaderNames.SET_COOKIE)
      .stream()
      .map(ClientCookieDecoder.LAX::decode)
      .forEach(c -> cookies.add(c.name(), ResponseCookie.from(c.name(), c.value())
                               .maxAge(c.maxAge())
                               .domain(c.domain())
                               .path(c.path())
                               .secure(c.isSecure())
                               .httpOnly(c.isHttpOnly())
                               .build()));
  return cookies;
}

代码示例来源:origin: dreamhead/moco

@Test
public void should_set_and_recognize_cookie_with_domain() throws IOException {
  runWithConfiguration("cookie.json");
  Cookie decodeCookie = getCookie("/cookie-with-domain");
  assertThat(decodeCookie.name(), is("login"));
  assertThat(decodeCookie.value(), is("true"));
  assertThat(decodeCookie.domain(), is("github.com"));
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

harCookie.setValue(cookie.value());
harCookie.setDomain(cookie.domain());
harCookie.setHttpOnly(cookie.isHttpOnly());
harCookie.setPath(cookie.path());

代码示例来源:origin: wildfly/wildfly

if (cookie.domain() != null) {
  add(buf, CookieHeaderNames.DOMAIN, cookie.domain());

代码示例来源:origin: lets-blade/blade

/**
 * Parse netty cookie to {@link Cookie}.
 *
 * @param nettyCookie netty raw cookie instance
 */
private void parseCookie(io.netty.handler.codec.http.cookie.Cookie nettyCookie) {
  var cookie = new Cookie();
  cookie.name(nettyCookie.name());
  cookie.value(nettyCookie.value());
  cookie.httpOnly(nettyCookie.isHttpOnly());
  cookie.path(nettyCookie.path());
  cookie.domain(nettyCookie.domain());
  cookie.maxAge(nettyCookie.maxAge());
  this.cookies.put(cookie.name(), cookie);
}

代码示例来源:origin: lets-blade/blade

/**
 * Parse netty cookie to {@link Cookie}.
 *
 * @param nettyCookie netty raw cookie instance
 */
private void parseCookie(io.netty.handler.codec.http.cookie.Cookie nettyCookie) {
  var cookie = new Cookie();
  cookie.name(nettyCookie.name());
  cookie.value(nettyCookie.value());
  cookie.httpOnly(nettyCookie.isHttpOnly());
  cookie.path(nettyCookie.path());
  cookie.domain(nettyCookie.domain());
  cookie.maxAge(nettyCookie.maxAge());
  this.cookies.put(cookie.name(), cookie);
}

代码示例来源:origin: vert-x3/vertx-web

@Override
public String getDomain() {
 return nettyCookie.domain();
}

代码示例来源:origin: line/armeria

assertThat(setCookie.name()).isEqualTo("a");
assertThat(setCookie.value()).isEqualTo("1");
assertThat(setCookie.domain()).isEqualTo("http://localhost");
assertThat(setCookie.path()).isEqualTo("/");
assertThat(setCookie.maxAge()).isEqualTo(Duration.ofSeconds(60).getSeconds());

代码示例来源:origin: com.github.mjeanroy/rest-assert-core

@Override
public String getDomain() {
  return cookie.domain();
}

代码示例来源:origin: io.vertx/vertx-web

@Override
public String getDomain() {
 return nettyCookie.domain();
}

代码示例来源:origin: org.jooby/jooby-netty

private org.jooby.Cookie cookie(final Cookie c) {
 org.jooby.Cookie.Definition cookie = new org.jooby.Cookie.Definition(c.name(), c.value());
 Optional.ofNullable(c.domain()).ifPresent(cookie::domain);
 Optional.ofNullable(c.path()).ifPresent(cookie::path);
 return cookie.toCookie();
}

代码示例来源:origin: HotelsDotCom/styx

private static ResponseCookie convert(Cookie cookie) {
  String value = cookie.wrap() ? quote(cookie.value()) : cookie.value();
  return responseCookie(cookie.name(), value)
      .domain(cookie.domain())
      .path(cookie.path())
      .maxAge(cookie.maxAge())
      .httpOnly(cookie.isHttpOnly())
      .secure(cookie.isSecure())
      .build();
}

相关文章