Search in sources :

Example 21 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1ValueUTF8.

@Test
public void v1ValueUTF8() {
    String value = "⌀";
    Cookie cookie = new Cookie("foo", value);
    cookie.setVersion(1);
    doTest(cookie, (String) null, "foo=" + value);
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 22 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v0ValueContainsBackslash.

@Test
public void v0ValueContainsBackslash() {
    Cookie cookie = new Cookie("foo", "a\\b");
    doTestDefaults(cookie, "foo=\"a\\\\b\"; Version=1", null);
    doTestAllowSeparators(cookie, "foo=a\\b", null);
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 23 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1ValueContainsComma.

@Test
public void v1ValueContainsComma() {
    Cookie cookie = new Cookie("foo", "a,b");
    cookie.setVersion(1);
    doTest(cookie, "foo=\"a,b\"; Version=1", null);
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 24 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1ValueContainsBackslashAndQuote.

@Test
public void v1ValueContainsBackslashAndQuote() {
    Cookie cookie = new Cookie("foo", "a\"b\\c");
    cookie.setVersion(1);
    doTest(cookie, "foo=\"a\\\"b\\\\c\"; Version=1", null);
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 25 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class ApplicationPushBuilder method generateCookieHeader.

private static String generateCookieHeader(List<Cookie> cookies, CookieProcessor cookieProcessor) {
    StringBuilder result = new StringBuilder();
    boolean first = true;
    for (Cookie cookie : cookies) {
        if (first) {
            first = false;
        } else {
            result.append(';');
        }
        // The cookie header value generated by the CookieProcessor was
        // originally intended for the Set-Cookie header on the response.
        // However, if passed a Cookie with just a name and value set it
        // will generate an appropriate header for the Cookie header on the
        // pushed request.
        result.append(cookieProcessor.generateHeader(cookie));
    }
    return result.toString();
}
Also used : Cookie(javax.servlet.http.Cookie)

Aggregations

Cookie (javax.servlet.http.Cookie)522 Test (org.junit.Test)207 HttpServletRequest (javax.servlet.http.HttpServletRequest)84 HttpServletResponse (javax.servlet.http.HttpServletResponse)61 IOException (java.io.IOException)45 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)44 ServletException (javax.servlet.ServletException)40 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)32 HashMap (java.util.HashMap)28 HttpSession (javax.servlet.http.HttpSession)26 Locale (java.util.Locale)23 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)23 HttpCookie (java.net.HttpCookie)19 Properties (java.util.Properties)19 Date (java.util.Date)18 PrintWriter (java.io.PrintWriter)17 ArrayList (java.util.ArrayList)17 Map (java.util.Map)16 MvcResult (org.springframework.test.web.servlet.MvcResult)15 ResultMatcher (org.springframework.test.web.servlet.ResultMatcher)15