use of io.netty.handler.codec.http.cookie.Cookie in project moco by dreamhead.
the class MocoCookieStandaloneTest method should_set_and_recognize_cookie_with_max_age.
@Test
public void should_set_and_recognize_cookie_with_max_age() throws IOException {
runWithConfiguration("cookie.json");
Cookie decodeCookie = getCookie("/cookie-with-max-age");
assertThat(decodeCookie.name(), is("login"));
assertThat(decodeCookie.value(), is("true"));
assertThat(decodeCookie.maxAge(), is(3600L));
}
use of io.netty.handler.codec.http.cookie.Cookie in project moco by dreamhead.
the class MocoCookieStandaloneTest method should_set_and_recognize_cookie_with_domain.
@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"));
}
use of io.netty.handler.codec.http.cookie.Cookie in project moco by dreamhead.
the class MocoCookieStandaloneTest method should_set_and_recognize_cookie.
@Test
public void should_set_and_recognize_cookie() throws IOException {
runWithConfiguration("cookie.json");
Cookie decodeCookie = getCookie("/cookie");
assertThat(decodeCookie.name(), is("login"));
assertThat(decodeCookie.value(), is("true"));
}
use of io.netty.handler.codec.http.cookie.Cookie in project moco by dreamhead.
the class MocoCookieStandaloneTest method should_set_and_recognize_cookie_with_secure.
@Test
public void should_set_and_recognize_cookie_with_secure() throws IOException {
runWithConfiguration("cookie.json");
Cookie decodeCookie = getCookie("/cookie-with-secure");
assertThat(decodeCookie.name(), is("login"));
assertThat(decodeCookie.value(), is("true"));
assertThat(decodeCookie.isSecure(), is(true));
}
use of io.netty.handler.codec.http.cookie.Cookie in project ratpack by ratpack.
the class DefaultRequest method oneCookie.
public String oneCookie(String name) {
Cookie found = null;
List<Cookie> allFound = null;
for (Cookie cookie : getCookies()) {
if (cookie.name().equals(name)) {
if (found == null) {
found = cookie;
} else if (allFound == null) {
allFound = new ArrayList<>(2);
allFound.add(found);
} else {
allFound.add(cookie);
}
}
}
if (found == null) {
return null;
} else if (allFound != null) {
StringBuilder s = new StringBuilder("Multiple cookies with name '").append(name).append("': ");
int i = 0;
for (Cookie cookie : allFound) {
s.append(cookie.toString());
if (++i < allFound.size()) {
s.append(", ");
}
}
throw new IllegalStateException(s.toString());
} else {
return found.value();
}
}
Aggregations