본문 바로가기

Invalid character found in the request target

* catalina.out 로그


29-Sep-2019 15:12:51.096 INFO [http-nio-8080-exec-29] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header

 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

        java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

                at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:483)

                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)

                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)

                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)

                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

                at java.lang.Thread.run(Thread.java:748)


Tomcat 8.0.39 버전부터 Query String 에 RFC 7230과 RFC 3986 문서에서 정의되지 않은 문자열을 포함할 경우(^`\|{}[] 같은 특수문자) 발생하는 400 오류(Bad Request) 이다. server.xml 에서 요청받는 Connector 태그에 relaxedQueryChars 속성을 추가하고 허용할 문자열을 정의하여 해결한다.


<Connector port="8080" protocol="HTTP/1.1" ... relaxedQueryChars="^`\|{}[]" />

<Connector port="8443" protocol="HTTP/1.1" ... relaxedQueryChars="^`\|{}[]" />