In addition to bug 32429, there are other issues I found with the CGI servlet. There was a type-o in sending the content to the process, a problem with printing debug output, and a problem processing large content. The large content issue is the big one. The problem is the existing 4.1.31 code is this: int lenRead = stdin.read(content); when it should be in some sort of read loop to ensure all the data is read. I don't know if fix I did to the toString() and blanksToString() is valid, but I was repeatedly getting: java.lang.ClassCastException at dsi.app.tomcat.DCGIServlet$CGIEnvironment.toString (DCGIServlet.java:1241) at dsi.app.tomcat.DCGIServlet.doGet(DCGIServlet.java:596) at dsi.app.tomcat.DCGIServlet.doPost(DCGIServlet.java:544) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) ... Attached is the file I made to fix the issues we were having. It is based on the 4.1.31 source code and a diff with tell what changes I made. The 5.0.28 source looks similar to the 4.1 source and so will have the problem as well.
Created attachment 13584 [details] A working CGI servlet class Don't know what type of file a "patch" file is supposed to be, but this the fix for the large file issue we were having.
Patches are supposed to be in diff -u format, not the whole file. For this and other information, please read http://www.apache.org/dev/contributors.html#patches.
Everything but the toString() issue has been fixed as a result of fixing other bugs. Fix for this has been applied to 4.1.x and 5.5.x The root cause of the cast exception is at line 1710 (for CVS revision 1.31 in TC4.1.x) where the content length is added as an integer rather than as a string. I have fixed the root cause rather than apply your toString() changes. Thanks again for your CGI bug reports. If you find any more, let us know.