Author: markt Date: Sun Mar 9 10:19:00 2008 New Revision: 635297 URL: http://svn.apache.org/viewvc?rev=635297&view=rev Log: Fix bug 44562. HEAD requests fail with rd.include(). Patch provided by David Jencks.
Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpServlet.java?rev=635297&r1=635296&r2=635297&view=diff ============================================================================== --- tomcat/trunk/java/javax/servlet/http/HttpServlet.java (original) +++ tomcat/trunk/java/javax/servlet/http/HttpServlet.java Sun Mar 9 10:19:00 2008 @@ -23,7 +23,6 @@ import java.lang.reflect.Method; import java.text.MessageFormat; import java.util.Enumeration; -import java.util.Locale; import java.util.ResourceBundle; import javax.servlet.GenericServlet; @@ -721,155 +720,51 @@ /* - * A response that includes no body, for use in (dumb) "HEAD" support. + * A response wrapper for use in (dumb) "HEAD" support. * This just swallows that body, counting the bytes in order to set - * the content length appropriately. All other methods delegate directly - * to the HTTP Servlet Response object used to construct this one. + * the content length appropriately. All other methods delegate to the + * wrapped HTTP Servlet Response object. */ // file private -class NoBodyResponse implements HttpServletResponse { - private HttpServletResponse resp; +class NoBodyResponse extends HttpServletResponseWrapper { private NoBodyOutputStream noBody; private PrintWriter writer; private boolean didSetContentLength; // file private NoBodyResponse(HttpServletResponse r) { - resp = r; + super(r); noBody = new NoBodyOutputStream(); } // file private void setContentLength() { if (!didSetContentLength) - resp.setContentLength(noBody.getContentLength()); + super.setContentLength(noBody.getContentLength()); } // SERVLET RESPONSE interface methods public void setContentLength(int len) { - resp.setContentLength(len); + super.setContentLength(len); didSetContentLength = true; } - public void setCharacterEncoding(String charset) - { resp.setCharacterEncoding(charset); } - - public void setContentType(String type) - { resp.setContentType(type); } - - public String getContentType() - { return resp.getContentType(); } - - public ServletOutputStream getOutputStream() throws IOException - { return noBody; } + public ServletOutputStream getOutputStream() throws IOException { + return noBody; + } - public String getCharacterEncoding() - { return resp.getCharacterEncoding(); } + public PrintWriter getWriter() throws UnsupportedEncodingException { - public PrintWriter getWriter() throws UnsupportedEncodingException - { if (writer == null) { - OutputStreamWriter w; + OutputStreamWriter w; w = new OutputStreamWriter(noBody, getCharacterEncoding()); writer = new PrintWriter(w); } return writer; } - - public void setBufferSize(int size) throws IllegalStateException - { resp.setBufferSize(size); } - - public int getBufferSize() - { return resp.getBufferSize(); } - - public void reset() throws IllegalStateException - { resp.reset(); } - - public void resetBuffer() throws IllegalStateException - { resp.resetBuffer(); } - - public boolean isCommitted() - { return resp.isCommitted(); } - - public void flushBuffer() throws IOException - { resp.flushBuffer(); } - - public void setLocale(Locale loc) - { resp.setLocale(loc); } - - public Locale getLocale() - { return resp.getLocale(); } - - - // HTTP SERVLET RESPONSE interface methods - - public void addCookie(Cookie cookie) - { resp.addCookie(cookie); } - - public boolean containsHeader(String name) - { return resp.containsHeader(name); } - - /** @deprecated */ - public void setStatus(int sc, String sm) - { resp.setStatus(sc, sm); } - - public void setStatus(int sc) - { resp.setStatus(sc); } - - public void setHeader(String name, String value) - { resp.setHeader(name, value); } - - public void setIntHeader(String name, int value) - { resp.setIntHeader(name, value); } - - public void setDateHeader(String name, long date) - { resp.setDateHeader(name, date); } - - public void sendError(int sc, String msg) throws IOException - { resp.sendError(sc, msg); } - - public void sendError(int sc) throws IOException - { resp.sendError(sc); } - - public void sendRedirect(String location) throws IOException - { resp.sendRedirect(location); } - - public String encodeURL(String url) - { return resp.encodeURL(url); } - - public String encodeRedirectURL(String url) - { return resp.encodeRedirectURL(url); } - - public void addHeader(String name, String value) - { resp.addHeader(name, value); } - - public void addDateHeader(String name, long value) - { resp.addDateHeader(name, value); } - - public void addIntHeader(String name, int value) - { resp.addIntHeader(name, value); } - - - /** - * @deprecated As of Version 2.1, replaced by - * [EMAIL PROTECTED] HttpServletResponse#encodeURL}. - * - */ - public String encodeUrl(String url) - { return this.encodeURL(url); } - - - /** - * @deprecated As of Version 2.1, replaced by - * [EMAIL PROTECTED] HttpServletResponse#encodeRedirectURL}. - * - */ - public String encodeRedirectUrl(String url) - { return this.encodeRedirectURL(url); } - } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]