cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java CoyoteRequest.java

2004-01-05 Thread larryi
larryi  2004/01/05 18:06:26

  Modified:coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java
CoyoteRequest.java
  Log:
  Port convertURI() method so URIEncoding setting has the desired effect.
  
  Revision  ChangesPath
  1.25  +62 -6 
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java
  
  Index: CoyoteAdapter.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CoyoteAdapter.java11 Dec 2003 21:35:24 -  1.24
  +++ CoyoteAdapter.java6 Jan 2004 02:06:26 -   1.25
  @@ -68,6 +68,7 @@
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletRequest;
   
  +import org.apache.tomcat.util.buf.B2CConverter;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.CharChunk;
   import org.apache.tomcat.util.buf.MessageBytes;
  @@ -220,7 +221,7 @@
*/
   protected void postParseRequest(Request req, CoyoteRequest request,
   Response res, CoyoteResponse response)
  -throws IOException {
  +throws Exception {
   // XXX the processor needs to set a correct scheme and port prior to this 
point, 
   // in ajp13 protocols dont make sense to get the port from the connector..
   // XXX the processor may have set a correct scheme and port prior to this 
point, 
  @@ -268,7 +269,6 @@
   res.setMessage(Invalid URI);
   throw ioe;
   }
  -req.decodedURI().setEncoding(UTF-8);
   
   // Normalize decoded URI
   if (!normalize(req.decodedURI())) {
  @@ -277,6 +277,9 @@
   throw new IOException(Invalid URI);
   }
   
  +// URI character decoding
  +convertURI(req.decodedURI(), request);
  +
   // Parse session Id
   parseSessionId(req, request);
   
  @@ -293,6 +296,7 @@
   // Redoing the URI decoding
   req.decodedURI().duplicate(req.requestURI());
   req.getURLDecoder().convert(req.decodedURI(), true);
  +convertURI(req.decodedURI(), request);
   }
   }
   
  @@ -512,6 +516,58 @@
   
   // Return the normalized path that we have completed
   return (normalized);
  +
  +}
  +
  +
  +/**
  + * Character conversion of the URI.
  + */
  +protected void convertURI(MessageBytes uri, CoyoteRequest request) 
  +throws Exception {
  +
  +ByteChunk bc = uri.getByteChunk();
  +CharChunk cc = uri.getCharChunk();
  +cc.allocate(bc.getLength(), -1);
  +
  +String enc = connector.getURIEncoding();
  +if (enc != null) {
  +B2CConverter conv = request.getURIConverter();
  +try {
  +if (conv == null) {
  +conv = new B2CConverter(enc);
  +request.setURIConverter(conv);
  +} else {
  +conv.recycle();
  +}
  +} catch (IOException e) {
  +// Ignore
  +log(Invalid URI encoding; using HTTP default, e);
  +connector.setURIEncoding(null);
  +}
  +if (conv != null) {
  +try {
  +conv.convert(bc, cc);
  +uri.setChars(cc.getBuffer(), cc.getStart(), 
  + cc.getLength());
  +return;
  +} catch (IOException e) {
  +if (debug = 1) {
  +log(Invalid URI character encoding; trying ascii, e);
  +}
  +cc.recycle();
  +}
  +}
  +}
  +
  +// Default encoding: fast conversion
  +byte[] bbuf = bc.getBuffer();
  +char[] cbuf = cc.getBuffer();
  +int start = bc.getStart();
  +for (int i = 0; i  bc.getLength(); i++) {
  +cbuf[i] = (char) (bbuf[i + start]  0xff);
  +}
  +uri.setChars(cbuf, 0, bc.getLength());
   
   }
   
  
  
  
  1.36  +27 -4 
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java
  
  Index: CoyoteRequest.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- CoyoteRequest.java12 Dec 2003 02:44:34 -  1.35
  +++ CoyoteRequest.java6 Jan 2004 02:06:26 -   1.36
  @@ -110,6 +110,7 @@
   import 

cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java CoyoteRequest.java

2002-10-20 Thread billbarker
billbarker2002/10/20 15:48:49

  Modified:coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java
CoyoteRequest.java
  Log:
  Arrange to have the SSL attributes in the CoyoteRequest so that they show up for 
getAttributeNames.
  
  Fix for bug #13658
  Reported By: [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.12  +11 -5 
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java
  
  Index: CoyoteAdapter.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CoyoteAdapter.java2 Oct 2002 05:29:53 -   1.11
  +++ CoyoteAdapter.java20 Oct 2002 22:48:49 -  1.12
  @@ -306,7 +306,13 @@
   parseCookies(req, request);
   
   // Set the SSL properties
  - res.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,request.getRequest());
  + if( request.isSecure() ) {
  + res.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,request.getRequest());
  + //Set up for getAttributeNames
  + request.getAttribute(Globals.CERTIFICATES_ATTR);
  + request.getAttribute(Globals.CIPHER_SUITE_ATTR);
  + request.getAttribute(Globals.KEY_SIZE_ATTR);
  + }
   
   // Set the remote principal
   String principal = req.getRemoteUser().toString();
  
  
  
  1.27  +7 -5  
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java
  
  Index: CoyoteRequest.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- CoyoteRequest.java23 Sep 2002 00:12:26 -  1.26
  +++ CoyoteRequest.java20 Oct 2002 22:48:49 -  1.27
  @@ -790,8 +790,10 @@
   return(attr);
   
   attr =  coyoteRequest.getAttribute(name);
  -if(attr != null)
  +if(attr != null) {
  +attributes.put(name, attr);
   return attr;
  +}
   // XXX Should move to Globals
   if(Constants.SSL_CERTIFICATE_ATTR.equals(name)) {
   coyoteRequest.action(ActionCode.ACTION_REQ_SSL_CERTIFICATE, null);
  
  
  

--
To unsubscribe, e-mail:   mailto:tomcat-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org