Dear Tomcat team, Good evening, I have encountered the following problem while using Spring boot: My version of Spring boot is 2.4.0 and JDK version is 1.8. The interface code for the Controller is as follows:
@RestController
public class HelloController {
@RequestMapping("/hello")
public Object hello(@RequestParam(value = "name") String name) {
name+="ok!";
return "ok";
}
}
I sent a curl request to the server through the terminal with the following request code:
curl -X POST "http://localhost:8080/hello?name=world"
At this point the following exception appears in my log:
2023-12-28 21:39:20.690 DEBUG 95860 --- [nio-8080-exec-2] o.a.coyote.http11.Http11InputBuffer : Before fill(): [true], parsingRequestLine: [true], parsingRequestLinePhase: [0], parsingRequestLineStart: [0], byteBuffer.position() [0]
2023-12-28 21:39:20.690 DEBUG 95860 --- [nio-8080-exec-2] o.a.tomcat.util.net.SocketWrapperBase : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@4adb5b2d:org.apache.tomcat.util.net.NioChannel@7d089058:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:62826]], Read from buffer: [0]
2023-12-28 21:39:22.985 DEBUG 95860 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
java.io.EOFException: null
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1231) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1141) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:795) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:359) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.39.jar:9.0.39]
at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Combined with some approaches from other developers, I thought long and hard and made the following attempt: - Modify my curl request to tell me the Context-Length in the request header. - Send the request with "Transfer-Encoding=chunked" in the request header. - Set the parameter server.ssl.enable=false in application.properties.
However, none of the above methods solved the problem, so I would like to talk to you in detail about the cause of this exception and effective ideas to solve it. In addition, in one of the issues I mentioned last week, when the body portion of the request body exceeds maxSwallowSize, it does not throw the maxSwallowSize exceeded exception, but throws an EOFException, is there a need for improvement here.
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Additionally if you meant to report a bug to Tomcat, please check out this page: https://tomcat.apache.org/bugreport.html