From 3d89dabb4bf7870667d81417bdfdb0e63055f19b Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Sep 2016 20:18:49 -0700 Subject: [PATCH] Document how to use LegacyCookieProcessor Closes gh-6827 --- spring-boot-docs/src/main/asciidoc/howto.adoc | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 7eb1462088..8e4f603c65 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -772,6 +772,38 @@ HTTPS connector: +[[howto-use-tomcat-legacycookieprocessor]] +=== Use Tomcat's LegacyCookieProcessor +The embedded Tomcat used by Spring Boot does not support "Version 0" of the Cookie +format out of the box, and you may see the following error: + +[indent=0] +---- + java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value +---- + +If at all possible, you should consider updating your code to only store values +compliant with later Cookie specifications. If, however, you're unable to change the +way that cookies are written, you can instead configure Tomcat to use a +`LegacyCookieProcessor`. To switch to the `LegacyCookieProcessor` use a +`TomcatContextCustomizer` bean: + +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- + @Bean + public TomcatContextCustomizer customizer() { + return new TomcatContextCustomizer() { + + void customize(Context context) { + context.setCookieProcessor(new LegacyCookieProcessor()); + } + + }; + } +} + + + [[howto-use-jetty-instead-of-tomcat]] === Use Jetty instead of Tomcat The Spring Boot starters (`spring-boot-starter-web` in particular) use Tomcat as an