billbarker 2003/07/12 01:35:39 Modified: src/share/org/apache/tomcat/modules/generators StaticInterceptor.java Log: Add support to the "Default Servlet" for the HTTP/1.1 methods "OPTIONS" and "TRACE" Fix for Bug #21454 (which was technically INVALID, until the CoyoteConnetor allowed for HTTP/1.1 requests). Revision Changes Path 1.27 +33 -1 jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java Index: StaticInterceptor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- StaticInterceptor.java 26 Jul 2002 04:40:15 -0000 1.26 +++ StaticInterceptor.java 12 Jul 2003 08:35:39 -0000 1.27 @@ -174,6 +174,13 @@ String pathInfo=req.servletPath().toString(); if( pathInfo==null ) pathInfo=""; + if( debug > 0 ) log("Method: " + req.method()); + if(req.method().equalsIgnoreCase("OPTIONS") || + req.method().equalsIgnoreCase("TRACE")) { + req.setHandler( ctx.getServletByName( "tomcat.fileHandler")); + return 0; + } + String absPath=FileUtil.safePath( ctx.getAbsolutePath(), pathInfo); @@ -409,12 +416,18 @@ public void doService(Request req, Response res) throws Exception { + if(req.method().equalsIgnoreCase("OPTIONS")) { + doOptions(req, res); + return; + } else if(req.method().equalsIgnoreCase("TRACE")) { + doTrace(req, res); + return; + } // if we are in include, with req==original request // - just use the current sub-request Request subReq=req; if(req.getChild()!=null) subReq=req.getChild(); - Context ctx=subReq.getContext(); // Use "javax.servlet.include.servlet_path" for path if defined. // ErrorHandler places the path here when invoking an error page. @@ -491,6 +504,25 @@ MimeHeaders headers=res.getMimeHeaders(); headers.setValue( name ).setTime( value ); } + } + void doOptions(Request req, Response res) + throws IOException { + res.addHeader("Allow","HEAD, GET, POST, OPTIONS, TRACE"); + } + void doTrace(Request req, Response res) + throws IOException { + String CRLF = "\r\n"; + res.setContentType("message/http"); + StringBuffer resp = new StringBuffer(); + Enumeration headers = req.getHeaderNames(); + while( headers.hasMoreElements() ) { + String hName = (String)headers.nextElement(); + String hValue = (String)req.getHeader(hName); + resp.append(CRLF).append(hName).append(": ").append(hValue); + } + res.setContentLength(resp.length()); + Writer out = res.getBuffer(); + out.write(resp.toString()); } /** All path checks that were part of DefaultServlet
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]