use of io.undertow.server.handlers.Cookie in project spring-framework by spring-projects.
the class UndertowServerHttpRequest method initCookies.
@Override
protected MultiValueMap<String, HttpCookie> initCookies() {
MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>();
for (String name : this.exchange.getRequestCookies().keySet()) {
Cookie cookie = this.exchange.getRequestCookies().get(name);
HttpCookie httpCookie = new HttpCookie(name, cookie.getValue());
cookies.add(name, httpCookie);
}
return cookies;
}
use of io.undertow.server.handlers.Cookie in project spring-framework by spring-projects.
the class UndertowServerHttpResponse method applyCookies.
@Override
protected void applyCookies() {
for (String name : getCookies().keySet()) {
for (ResponseCookie httpCookie : getCookies().get(name)) {
Cookie cookie = new CookieImpl(name, httpCookie.getValue());
if (!httpCookie.getMaxAge().isNegative()) {
cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds());
}
httpCookie.getDomain().ifPresent(cookie::setDomain);
httpCookie.getPath().ifPresent(cookie::setPath);
cookie.setSecure(httpCookie.isSecure());
cookie.setHttpOnly(httpCookie.isHttpOnly());
this.exchange.getResponseCookies().putIfAbsent(name, cookie);
}
}
}
use of io.undertow.server.handlers.Cookie in project undertow by undertow-io.
the class CookiesTestCase method testRequestCookieDomainPathVersion.
@Test
public void testRequestCookieDomainPathVersion() {
Map<String, Cookie> cookies = Cookies.parseRequestCookies(1, false, Arrays.asList("CUSTOMER=WILE_E_COYOTE; $Domain=LOONEY_TUNES; $Version=1; $Path=/"));
Assert.assertFalse(cookies.containsKey("$Domain"));
Assert.assertFalse(cookies.containsKey("$Version"));
Assert.assertFalse(cookies.containsKey("$Path"));
Cookie cookie = cookies.get("CUSTOMER");
Assert.assertEquals("CUSTOMER", cookie.getName());
Assert.assertEquals("WILE_E_COYOTE", cookie.getValue());
Assert.assertEquals("LOONEY_TUNES", cookie.getDomain());
Assert.assertEquals(1, cookie.getVersion());
Assert.assertEquals("/", cookie.getPath());
}
use of io.undertow.server.handlers.Cookie in project undertow by undertow-io.
the class CookiesTestCase method testEqualsInValueAllowed.
@Test
public void testEqualsInValueAllowed() {
Map<String, Cookie> cookies = Cookies.parseRequestCookies(1, true, Arrays.asList("CUSTOMER=WILE_E_COYOTE=THE_COYOTE"));
Cookie cookie = cookies.get("CUSTOMER");
Assert.assertNotNull(cookie);
Assert.assertEquals("WILE_E_COYOTE=THE_COYOTE", cookie.getValue());
}
use of io.undertow.server.handlers.Cookie in project undertow by undertow-io.
the class CookiesTestCase method testEqualsInValueAllowedInQuotedValue.
@Test
public void testEqualsInValueAllowedInQuotedValue() {
Map<String, Cookie> cookies = Cookies.parseRequestCookies(2, true, Arrays.asList("CUSTOMER=\"WILE_E_COYOTE=THE_COYOTE\"; SHIPPING=FEDEX"));
Assert.assertEquals(2, cookies.size());
Cookie cookie = cookies.get("CUSTOMER");
Assert.assertNotNull(cookie);
Assert.assertEquals("WILE_E_COYOTE=THE_COYOTE", cookie.getValue());
cookie = cookies.get("SHIPPING");
Assert.assertNotNull(cookie);
Assert.assertEquals("FEDEX", cookie.getValue());
}
Aggregations