Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Tomcat server to send the Keep-alive header in http response

We have an application running on a tomcat 7 server, and we want the http responses that send back to the client has the keep-alive header in it. Is there a way to change some configuration, like the server.xml to make this happen? Thanks a lot!

like image 908
Wei Avatar asked Jul 22 '14 19:07

Wei


People also ask

How do I enable HTTP keep-alive response headers?

To enable Keep-Alive, you need to explicitly request it via the HTTP header by accessing . htaccess or the main configuration file of your web server. If you turn on Keep-Alive, the HTTP response header will show Connection: keep-alive.

How do I keep my HTTP request alive?

The Keep-Alive header is a general-type header. This header is used to hint at how the connection may be used to set a timeout and a maximum amount of requests. It can also be used to allow a single TCP connection to remain open for multiple HTTP requests/responses (default HTTP connection closed after each request).

What is maxPostSize in Tomcat?

maxPostSize. The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

What is maxThreads in Tomcat?

By default, Tomcat sets maxThreads to 200, which represents the maximum number of threads allowed to run at any given time. You can also specify values for the following parameters: minSpareThreads : the minimum number of threads that should be running at all times.


1 Answers

In HTTP/1.1, connections are assumed to be keep-alive, unless otherwise specified (by "Connection: close" header). Therefore it is usually unnecessary to explicitly set keep-alive header.

Of course, you can always add a servlet filter that sets whatever headers that you need.

like image 145
ZhongYu Avatar answered Oct 30 '22 09:10

ZhongYu