Apache/JServ 1.0 "cannot scan servlet headers"

Apache/JServ 1.0 "cannot scan servlet headers"

Post by ben_kel.. » Wed, 11 Aug 1999 04:00:00

After upgrading to Apache 1.3.6 and JServ 1.0, I was quite impressed,
until I started getting error messages from my servlets, and getting
"cannot scan servlet headers" in my mod_jserve.log file.

Anyway, it turned out to be a problem in jserv_ajpv11.c in the JServ
code. (The bug may also exist in some versions of jserv_ajpv12.c.)

patch that should fix the problem. Patch this against jserv_ajpv11.c
in the src/c directory in the JServ code.

------- jserv_ajpv11.c -------
*** /tmp/da004Fx        Thu Jan  1 10:00:00 1970
--- jserv_ajpv11.c      Fri Aug  6 10:13:41 1999
*** 419,428 ****
      /* Receive the response from JServ */
      ap_hard_timeout("ajpv11-read", r);
      if (ret=ap_scan_script_header_err_buff(r,buffsocket,NULL)) {
!         ap_kill_timeout(r);
!         jserv_error(JSERV_LOG_EMERG,cfg,"ajp11: %s",
!                     "cannot scan servlet headers");
!         return SERVER_ERROR;

      /* Check for our Error headers */
--- 419,433 ----
      /* Receive the response from JServ */
      ap_hard_timeout("ajpv11-read", r);
      if (ret=ap_scan_script_header_err_buff(r,buffsocket,NULL)) {
!               ap_kill_timeout(r);
!         if( ret>=500 || ret < 0)
!           jserv_error(JSERV_LOG_EMERG,cfg,"ajp11: %s (%d)",
!                     "cannot scan servlet headers", ret);
!         r->status_line = NULL;
!         return ret;

      /* Check for our Error headers */

Also, I created a test servlet that demonstrates the bug. This
servlet will cause Apache to generate a 304 status when you reload
the servlet, as it supplies a "Last-Modified" header. Compile it
up, and load the page in your browser. Click reload/refresh. If
you have an unpatched version of jserv_ajpv11.c, you get a server error
page. (Probably showing the error "OK")

================8<================ Tester.java ==
 import javax.servlet.*;
 import javax.servlet.http.*;
 import java.io.*;

 public class Tester extends HttpServlet
     public void doGet(
         HttpServletRequest    request,
         HttpServletResponse response) throws ServletException,
             "Thu, 11 Feb 1999 22:25:49 GMT");

         PrintWriter out = new PrintWriter (response.getOutputStream());

         out.println("<title>Test Servlet</title>");
         out.println("<p>This servlet reports that it was last
modified " +
             "on Thu, 11 Feb 1999 22:25:49 GMT</p>");

    - Ben Kelley.



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


1. "malformed header" error (Apache 1.0/SCO) ?

I've recently compiled Apache 1.0.0 under SCO 3.4.2. The system was previously
running 0.6.5, and existing CGI programs in C are not running under the new
service. The error_log contains the message:

[Tue Jan 16 13:41:56 1996] access to /w/cgi-bin/srch failed for dbyrne.aba
soft.co.uk, reason: malformed header from script

I've run the program from the command line, and the output is as expected:

Content: text/html




This all appears valid, and the same cgi progs compiled on a Sun running
Solaris 2.4 work fine with the 1.0.0 Server, so it looks like a SCO problem.
When the cgi program exits, it is as a result of a failed select(2) call,
which it doesn't do under 0.6.5. The number of SpareServers/MaxServers etc
does not affect the problem.

The cgi progs are all called from URLs, no SSI involved.
Has anyone seen this or have any ideas ?


David Byrne, Abacus Software, London, UK              Tel: +44 (0)171 603 9877

Here's a koan: If you have ice-cream I will give you some. If you have none,
               I will take it away from you. (it's an ice-cream koan).

2. X setup

3. GETSERVBYNAME()????????????????????"""""""""""""

4. PPPD and permanent analog wire

5. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

6. ipchains : icmp type3+4, frozen connections

7. 'Cannot scan servlet headers' error

8. X setup specs for CPD-1304 Monitor?

9. Xlib: extension "RENDER" missing on display "ymserver.mydomain.de:1.0"

10. Type "(", ")" and "{", "}" in X...

11. My linux+Apache+mod_perl cannot recognize"print "Set-Cookie: cookie-name = Unique; "

12. Cannot Use "ifconfig" nor "iwconfig" effectively

13. "Too Big" and "This Region cannot be used" msgs from install.