Author: remm Date: Thu Jan 10 15:45:47 2013 New Revision: 1431444 URL: http://svn.apache.org/viewvc?rev=1431444&view=rev Log: - Add the ability to invoke the main service method as an API call, without having to fallback to bytes. - Add some utility get/set (one of which got removed after deprecation but is not necessarily that useless). - Both changes to make using the rewrite valve possible.
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/trunk/java/org/apache/catalina/connector/Request.java Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1431444&r1=1431443&r2=1431444&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Thu Jan 10 15:45:47 2013 @@ -609,39 +609,53 @@ public class CoyoteAdapter implements Ad MessageBytes decodedURI = req.decodedURI(); decodedURI.duplicate(req.requestURI()); - // Parse the path parameters. This will: - // - strip out the path parameters - // - convert the decodedURI to bytes - parsePathParameters(req, request); + if (decodedURI.getType() == MessageBytes.T_BYTES) { + // Parse the path parameters. This will: + // - strip out the path parameters + // - convert the decodedURI to bytes + parsePathParameters(req, request); - // URI decoding - // %xx decoding of the URL - try { - req.getURLDecoder().convert(decodedURI, false); - } catch (IOException ioe) { - res.setStatus(400); - res.setMessage("Invalid URI: " + ioe.getMessage()); - connector.getService().getContainer().logAccess( - request, response, 0, true); - return false; - } - // Normalization - if (!normalize(req.decodedURI())) { - res.setStatus(400); - res.setMessage("Invalid URI"); - connector.getService().getContainer().logAccess( - request, response, 0, true); - return false; - } - // Character decoding - convertURI(decodedURI, request); - // Check that the URI is still normalized - if (!checkNormalize(req.decodedURI())) { - res.setStatus(400); - res.setMessage("Invalid URI character encoding"); - connector.getService().getContainer().logAccess( - request, response, 0, true); - return false; + // URI decoding + // %xx decoding of the URL + try { + req.getURLDecoder().convert(decodedURI, false); + } catch (IOException ioe) { + res.setStatus(400); + res.setMessage("Invalid URI: " + ioe.getMessage()); + connector.getService().getContainer().logAccess( + request, response, 0, true); + return false; + } + // Normalization + if (!normalize(req.decodedURI())) { + res.setStatus(400); + res.setMessage("Invalid URI"); + connector.getService().getContainer().logAccess( + request, response, 0, true); + return false; + } + // Character decoding + convertURI(decodedURI, request); + // Check that the URI is still normalized + if (!checkNormalize(req.decodedURI())) { + res.setStatus(400); + res.setMessage("Invalid URI character encoding"); + connector.getService().getContainer().logAccess( + request, response, 0, true); + return false; + } + } else { + // The URL is chars or String, and has been sent using an in-memory + // protocol handler, we have to assume the URL has been properly + // decoded already + decodedURI.toChars(); + // Remove any path parameters + CharChunk uriCC = decodedURI.getCharChunk(); + int semicolon = uriCC.indexOf(';'); + if (semicolon > 0) { + decodedURI.setChars + (uriCC.getBuffer(), uriCC.getStart(), semicolon); + } } // Set the remote principal Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=1431444&r1=1431443&r2=1431444&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Thu Jan 10 15:45:47 2013 @@ -1002,6 +1002,14 @@ public class Request /** + * Set the content type for this Request. + */ + public void setContentType(String contentType) { + coyoteRequest.setContentType(contentType); + } + + + /** * Return the servlet input stream for this Request. The default * implementation returns a servlet input stream created by * <code>createInputStream()</code>. @@ -1831,6 +1839,16 @@ public class Request /** + * Get the decoded request URI. + * + * @return the URL decoded request URI + */ + public MessageBytes getDecodedRequestURIMB() { + return coyoteRequest.decodedURI(); + } + + + /** * Set the Principal who has been authenticated for this Request. This * value is also used to calculate the value to be returned by the * <code>getRemoteUser()</code> method. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org