Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tomcat compression

If compression is setup on tomcat, will it also compress data that is uploaded by the client - via browser/applet ?

like image 252
souser Avatar asked May 27 '10 23:05

souser


1 Answers

No, it won't. It only applies on the server response. The client has to compress the request data itself. It makes no sense to send the data from the client uncompressed over network to the server first and then compress over there. It won't have any benefits (i.e. saving network bandwidth and so on).

Compression of HTTP requests is however not part of the HTTP specification since a client can't know beforehand if a server would support it. It has to fire a whole request first. It's only specified for the HTTP responses. The server can determine based on the Accept-Encoding request header if the client supports compression or not and then handle accordingly.

In an applet, you can consider to send the data compressed using GZIPOutputStream. You'll only need to develop a specific servlet on the server side which listens on requests from the applet only and knows that it needs to decompress the HttpServletRequest#getInputStream() accordingly using GZIPInputStream

like image 158
BalusC Avatar answered Sep 23 '22 07:09

BalusC