Redirection blues

Brian Millett writes:
 > Hello,
 > 	Well after a bit of snooping around in the code & turning on
 > -trace, I found that the CgiResource was not returning a correct mime
 > header for the httpd (Jigsaw) server to handle.  What was missing was
 > "Content-length: 0"
 > ...
 > So I added the following to the handleCGIOutput method right after the
 > catches, before the return reply;
 > 
 > 
 > 	if ( reply.getStatus() == HTTP.MOVED_TEMPORARILY ) {
 > 	  String nocache[] = { "no-cache" };
 > 	  reply.setPragma(nocache);
 > 	  reply.setNoCache(null);
 > 	  reply.setContentLength(0);
 > 	}

I have a slight problem with this: the HTTP spec allows for a body in
a 302 reply, which means that the script emitting the redirect is
allowed to set Content-Length itself. I guess the code should read:

if ( reply.getStatus() == HTTP.MOVED_TEMPORARILY ) {
    if ( reply.getContentLength() < 0 ) {
        // The script didn't emit a content length [READ-ON]
        reply.setContentLength(0);
    }
}

Now, this doesn't work either. In fact your script should work even if
it doesn't emit a content length: in that case Jigsaw will chunk
encode the body (if the client is 1.1), or close the connection after
sending the reply (which is what should happen in your case). I'll try
it and fix it, will let you know.

Anselm.

Received on Wednesday, 18 December 1996 03:44:26 UTC