cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-11-19 Thread billbarker

billbarker01/11/19 21:38:30

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Handle missing '=' from RequestDispatcher.include.
  
  Fix for bug #4955
  Reported By: Gareth Cronin [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.19  +1 -0  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Parameters.java   2001/09/14 04:16:35 1.18
  +++ Parameters.java   2001/11/20 05:38:30 1.19
  @@ -542,6 +542,7 @@
int nameStart=pos;
int nameEnd=str.indexOf('=', nameStart );
int nameEnd2=str.indexOf('&', nameStart );
  + if( nameEnd2== -1 ) nameEnd2=end;
if( (nameEnd2!=-1 ) &&
( nameEnd==-1 || nameEnd > nameEnd2) ) {
nameEnd=nameEnd2;
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-09-13 Thread costin

costin  01/09/13 21:16:35

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Extra check, again result of a report from Bill Barker <[EMAIL PROTECTED]>.
  
  The name can become null if we have a conversion error ( i.e. the param contains 
invalid
  chars in the detected charset ).  Bill reported a more complex problem, with charset 
having
  a wrong value - but this is a corner case and I doubt there is anything anyone can do
  ( if the browser doesn't send the charset and the user changes the encoding
  during the session and it does so without first sending a page with the new encoding,
  I don't know any way we could guess the new encoding )
  
  Revision  ChangesPath
  1.18  +1 -0  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Parameters.java   2001/09/09 03:14:41 1.17
  +++ Parameters.java   2001/09/14 04:16:35 1.18
  @@ -317,6 +317,7 @@
   // incredibly inefficient data representation for parameters,
   // until we test the new one
   private void addParam( String key, String value ) {
  + if( key==null ) return;
String values[];
if (paramHashStringArray.containsKey(key)) {
String oldValues[] = (String[])paramHashStringArray.
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-09-08 Thread costin

costin  01/09/08 20:14:41

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Bug 3479: parameter parsing with a&b&c syntax ( no '=' ).
  
  Revision  ChangesPath
  1.17  +64 -14
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Parameters.java   2001/08/31 04:13:11 1.16
  +++ Parameters.java   2001/09/09 03:14:41 1.17
  @@ -359,13 +359,30 @@
log( "Bytes: " + new String( bytes, start, len ));
   
   do {
  + boolean noEq=false;
  + int valStart=-1;
  + int valEnd=-1;
  + 
int nameStart=pos;
int nameEnd=ByteChunk.indexOf(bytes, nameStart, end, '=' );
  - if( nameEnd== -1 ) nameEnd=end;
  - 
  - int valStart=nameEnd+1;
  - int valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
  - if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  + // Workaround for a&b&c encoding
  + int nameEnd2=ByteChunk.indexOf(bytes, nameStart, end, '&' );
  + if( (nameEnd2!=-1 ) &&
  + ( nameEnd==-1 || nameEnd > nameEnd2) ) {
  + nameEnd=nameEnd2;
  + noEq=true;
  + valStart=nameEnd;
  + valEnd=nameEnd;
  + if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + new 
String(bytes, nameStart, nameEnd-nameStart) );
  + }
  + if( nameEnd== -1 ) 
  + nameEnd=end;
  +
  + if( ! noEq ) {
  + valStart=nameEnd+1;
  + valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
  + if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  + }

pos=valEnd+1;

  @@ -381,7 +398,7 @@

try {
if( debug > 0 )
  - log( tmpName + "= " + tmpValue);
  + log( "Found " + tmpName + "= " + tmpValue);
   
if( urlDec==null ) {
urlDec=new UDecoder();   
  @@ -390,7 +407,7 @@
urlDec.convert( tmpValue );
   
if( debug > 0 )
  - log( tmpName + "= " + tmpValue);
  + log( "After url decoding " + tmpName + "= " + tmpValue);

addParam( tmpName.toString(), tmpValue.toString() );
} catch( IOException ex ) {
  @@ -410,13 +427,29 @@
if( debug>0 ) 
log( "Chars: " + new String( chars, start, len ));
   do {
  + boolean noEq=false;
int nameStart=pos;
  + int valStart=-1;
  + int valEnd=-1;
  + 
int nameEnd=CharChunk.indexOf(chars, nameStart, end, '=' );
  + int nameEnd2=CharChunk.indexOf(chars, nameStart, end, '&' );
  + if( (nameEnd2!=-1 ) &&
  + ( nameEnd==-1 || nameEnd > nameEnd2) ) {
  + nameEnd=nameEnd2;
  + noEq=true;
  + valStart=nameEnd;
  + valEnd=nameEnd;
  + if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + new 
String(chars, nameStart, nameEnd-nameStart) );
  + }
if( nameEnd== -1 ) nameEnd=end;
  -
  - int valStart=nameEnd+1;
  - int valEnd=CharChunk.indexOf(chars, valStart, end, '&');
  - if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  + 
  + if( ! noEq ) {
  + valStart=nameEnd+1;
  + valEnd=CharChunk.indexOf(chars, valStart, end, '&');
  + if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  + }
  + 
pos=valEnd+1;

if( nameEnd<=nameStart ) {
  @@ -501,13 +534,30 @@
log("String: " + str );

   do {
  + boolean noEq=false;
  + int valStart=-1;
  + int valEnd=-1;
  + 
int nameStart=pos;
int nameEnd=str.indexOf('=', nameStart );
  + int nameEnd2=str.indexOf('&', nameStart );
  + if( (nameEnd2!=-1 ) &&
  + ( nameEnd==-1 || nameEnd > nameEnd2) ) {
  + nameEnd=nameEnd2;
  + noEq=true;
  + valStart=nameEnd;
  + valEnd=nameEnd;
  + if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + 
str.substring(nameStart, nameEnd) );
  + }
  +
if( nameEnd== -1 ) nameEnd=end;
   
  - int valStart=nameEnd+1;
  - int valEnd=str.indexOf('&', valStart);
  - if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  + if( ! noEq ) {
  + valStart=nameEnd+1;
  + valEnd=str.indexOf

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-05-27 Thread costin

costin  01/05/27 16:16:20

  Modified:src/share/org/apache/tomcat/util/buf ByteChunk.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Removed the debug from Parameters.
  
  Added the indexOf() method in ByteChunk - it'll save the other 5-6 strings
  we allocated per request. ( the code is not in use right now ). We're
  close to zero allocations per "simple" request ( and soon parameter processing
  will also be very close to zero ).
  
  Revision  ChangesPath
  1.4   +20 -1 
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ByteChunk.java2001/05/26 17:17:01 1.3
  +++ ByteChunk.java2001/05/27 23:16:19 1.4
  @@ -560,6 +560,25 @@
}
return true;
   }
  +
  +public int indexOf( String src, int srcOff, int srcLen, int myOff ) {
  + char first=src.charAt( srcOff );
  +
  + // Look for first char 
  + int srcEnd=srcOff + srcLen;
  + 
  + for( int i=myOff; i< end - srcLen ; i++ ) {
  + if( buff[i] != first ) continue;
  + // found first char, now look for a match
  + int myPos=i+1;
  + for( int srcPos=srcOff; srcPos< srcEnd; ) {
  + if( buff[myPos++] != src.charAt( srcPos++ ))
  + break;
  + if( srcPos==srcEnd ) return i; // found it
  + }
  + }
  + return -1;
  +}
   
   //  Hash code  
   
  @@ -615,7 +634,7 @@
return -1;
   }
   
  -/** Find a character, no side effects.
  +/** Find a character, no side effects.
*  @returns index of char if found, -1 if not
*/
   public static int findChar( byte buf[], int start, int end, char c ) {
  
  
  
  1.13  +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Parameters.java   2001/05/26 17:24:17 1.12
  +++ Parameters.java   2001/05/27 23:16:19 1.13
  @@ -480,7 +480,7 @@
return sb.toString();
   }
   
  -private static int debug=1;
  +private static int debug=0;
   private void log(String s ) {
System.out.println("Parameters: " + s );
   }
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-05-26 Thread costin

costin  01/05/26 10:24:17

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Few big changes here...
  
  The "new" code is now in use ( has been here for few months, but we kept
  using the old code for safety ). The most important thing is that
  now we corectly decode ( if charset is provided ) - the old code didn't.
  
  There is still some old code in use ( only used by RequestDispatcher), but
  the common code is now fixed.
  
  Revision  ChangesPath
  1.12  +182 -84   
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Parameters.java   2001/02/20 03:14:11 1.11
  +++ Parameters.java   2001/05/26 17:24:17 1.12
  @@ -59,9 +59,7 @@
   
   package org.apache.tomcat.util.http;
   
  -import  org.apache.tomcat.util.buf.MessageBytes;
  -import  org.apache.tomcat.util.buf.CharChunk;
  -import  org.apache.tomcat.util.buf.ByteChunk;
  +import  org.apache.tomcat.util.buf.*;
   import  org.apache.tomcat.util.collections.MultiMap;
   import java.io.*;
   import java.util.*;
  @@ -72,6 +70,7 @@
* @author Costin Manolache
*/
   public final class Parameters extends MultiMap {
  +
   // Transition: we'll use the same Hashtable( String->String[] )
   // for the beginning. When we are sure all accesses happen through
   // this class - we can switch to MultiMap
  @@ -81,6 +80,9 @@
   
   MessageBytes queryMB;
   MimeHeaders  headers;
  +
  +UDecoder urlDec;
  +MessageBytes decodedQuery=new MessageBytes();
   
   public static final int INITIAL_SIZE=4;
   
  @@ -94,6 +96,8 @@
   private Parameters parent=null;
   private Parameters currentChild=null;
   
  +String encoding=null;
  +
   /**
* 
*/
  @@ -109,12 +113,18 @@
this.headers=headers;
   }
   
  +public void setEncoding( String s ) {
  + encoding=s;
  +}
  +
   public void recycle() {
super.recycle();
paramHashStringArray.clear();
didQueryParameters=false;
currentChild=null;
didMerge=false;
  + encoding=null;
  + decodedQuery.recycle();
   }
   
   //  Sub-request support 
  @@ -145,11 +155,13 @@
// set child to null !
if( currentChild==null ) {
currentChild=new Parameters();
  + currentChild.setURLDecoder( urlDec );
currentChild.parent=this;
return;
}
if( currentChild.child==null ) {
currentChild.child=new Parameters();
  + currentChild.setURLDecoder( urlDec );
currentChild.child.parent=currentChild;
} // it is not null if this object already had a child
// i.e. a deeper include() ( we keep it )
  @@ -205,9 +217,10 @@
*/
   private void merge() {
// recursive
  - //  System.out.println("Merging " + this + " with " +
  - // parent + " " + didMerge);
  - //System.out.println( "Before " + paramsAsString());
  + if( debug > 0 ) {
  + log("Before merging " + this + " " + parent + " " + didMerge );
  + log(  paramsAsString());
  + }
// Local parameters first - they take precedence as in spec.
handleQueryParameters();
   
  @@ -222,7 +235,8 @@
Hashtable parentProps=parent.paramHashStringArray;
merge2( paramHashStringArray , parentProps);
didMerge=true;
  - //System.out.println( "After " + paramsAsString());
  + if(debug > 0 )
  + log("After " + paramsAsString());
   }
   
   
  @@ -231,54 +245,34 @@
String[] values = getParameterValues(name);
   if (values != null) {
if( values.length==0 ) return "";
  - //System.out.println("XXX " + name + "=" + values[0] );
   return values[0];
   } else {
  - //  System.out.println("XXX " + name + "=null" );
return null;
   }
   }
   //  Processing 
  -
   /** Process the query string into parameters
*/
   public void handleQueryParameters() {
if( didQueryParameters ) return;

didQueryParameters=true;
  - if( queryMB==null )
  + if( debug > 0  )
  + log( "Decoding query " + queryMB + " " + encoding);
  + 
  + if( queryMB==null || queryMB.isNull() )
return;
  - String qString=queryMB.toString();
  - if(qString!=null) {
  - processFormData( qString );
  - }
  -}
  -
  -public void processParameters(String data) {
  - processFormData( data );
  -}
  -
  -// XXX ENCODING !!
  -public void proc

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-02-10 Thread costin

costin  01/02/10 15:28:17

  Modified:src/share/org/apache/tomcat/core OutputBuffer.java
Response.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Another small bug in Parameters.
  
  I am reasonably confident we have the right parameter ordering and
  RD and JSPs are working fine now ( with regard to parameters ).
  I have one more test to check in and I'll move to next issue.
  
  Revision  ChangesPath
  1.12  +9 -0  
jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- OutputBuffer.java 2001/01/07 00:10:33 1.11
  +++ OutputBuffer.java 2001/02/10 23:28:15 1.12
  @@ -107,9 +107,18 @@
   Request req;
   ContextManager cm;
   
  +public OutputBuffer() {
  + buf=new byte[defaultBufferSize];
  + cbuf=new char[defaultCharBufferSize];
  +}
  +
   public OutputBuffer(Response resp) {
buf=new byte[defaultBufferSize];
cbuf=new char[defaultCharBufferSize];
  + setResponse( resp );
  +}
  +
  +public void setResponse( Response resp ) {
this.resp=resp;
req=resp.getRequest();
cm=req.getContextManager();
  
  
  
  1.48  +1 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Response.java 2001/01/23 05:08:38 1.47
  +++ Response.java 2001/02/10 23:28:15 1.48
  @@ -270,7 +270,7 @@
   }
   
   public void finish() throws IOException {
  -oBuffer.close();
  + oBuffer.close();
ContextManager cm=request.getContextManager();
BaseInterceptor reqI[]= request.getContainer().
getInterceptors(Container.H_afterBody);
  
  
  
  1.10  +18 -2 
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Parameters.java   2001/02/10 21:17:42 1.9
  +++ Parameters.java   2001/02/10 23:28:17 1.10
  @@ -203,8 +203,9 @@
*/
   private void merge() {
// recursive
  - //System.out.println("Merging " + this + " with " +
  - //   parent + " " + didMerge);
  + //  System.out.println("Merging " + this + " with " +
  + // parent + " " + didMerge);
  + //System.out.println( "Before " + paramsAsString());
// Local parameters first - they take precedence as in spec.
handleQueryParameters();
   
  @@ -215,9 +216,11 @@
if( parent==null ) return;
   
// Add the parent props to the child ( lower precedence )
  + parent.merge();
Hashtable parentProps=parent.paramHashStringArray;
merge2( paramHashStringArray , parentProps);
didMerge=true;
  + //System.out.println( "After " + paramsAsString());
   }
   
   
  @@ -425,4 +428,17 @@
}
   }
   
  +public String paramsAsString() {
  + StringBuffer sb=new StringBuffer();
  + Enumeration en= paramHashStringArray.keys();
  + while( en.hasMoreElements() ) {
  + String k=(String)en.nextElement();
  + sb.append( k ).append("=");
  + String v[]=(String[])paramHashStringArray.get( k );
  + for( int i=0; i


cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-02-10 Thread costin

costin  01/02/10 13:17:42

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Fixes for NPE ( the new test )
  
  Revision  ChangesPath
  1.9   +9 -1  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Parameters.java   2001/02/07 07:01:30 1.8
  +++ Parameters.java   2001/02/10 21:17:42 1.9
  @@ -141,6 +141,11 @@
// create a new element in the linked list
// note that we reuse the child, if any - pop will not
// set child to null !
  + if( currentChild==null ) {
  + currentChild=new Parameters();
  + currentChild.parent=this;
  + return;
  + }
if( currentChild.child==null ) {
currentChild.child=new Parameters();
currentChild.child.parent=currentChild;
  @@ -198,7 +203,8 @@
*/
   private void merge() {
// recursive
  -
  + //System.out.println("Merging " + this + " with " +
  + //   parent + " " + didMerge);
// Local parameters first - they take precedence as in spec.
handleQueryParameters();
   
  @@ -235,6 +241,8 @@
if( didQueryParameters ) return;

didQueryParameters=true;
  + if( queryMB==null )
  + return;
String qString=queryMB.toString();
if(qString!=null) {
processFormData( qString );
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-02-06 Thread costin

costin  01/02/06 23:01:31

  Modified:src/share/org/apache/tomcat/core ContextManager.java
Request.java
   src/share/org/apache/tomcat/modules/server
Ajp12Interceptor.java Ajp13Interceptor.java
Http10Interceptor.java JNIConnectionHandler.java
   src/share/org/apache/tomcat/startup StopTomcat.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Fixed a number of probles with reading the request body.
  - moved the check for "available" in Request, and make sure all the
  adapters are checking if more data is to be expected.
  ( it used to be in the facade, but this is not the only place where the
  check must be made - it's much better to test it at the lower level )
  
  - few changes in how the POST data is pushed in Parameters.
  
  Note: reading the request body will be changed a bit to deal with the
  encoding problems, right now the parameters have hardcoded charset
  ( that was the original code ), and needs to be fixed.
  
  Revision  ChangesPath
  1.167 +3 -0  
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.166
  retrieving revision 1.167
  diff -u -r1.166 -r1.167
  --- ContextManager.java   2001/02/06 06:41:07 1.166
  +++ ContextManager.java   2001/02/07 07:01:23 1.167
  @@ -871,7 +871,10 @@
}
   
Request lr = new Request();
  + Response res = new Response();
lr.setContextManager( this );
  + lr.setResponse( res );
  + res.setRequest( lr );
lr.requestURI().setString( urlPath );
lr.queryString().setString(queryString );
   
  
  
  
  1.89  +69 -27jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- Request.java  2001/02/06 06:29:19 1.88
  +++ Request.java  2001/02/07 07:01:23 1.89
  @@ -137,9 +137,12 @@
   // Processed information ( redundant ! )
   protected Parameters params=new Parameters();
   //protected Hashtable parametersH = new Hashtable();
  -protected boolean didReadFormData;
  +protected boolean didReadFormData=false;
   
   protected int contentLength = -1;
  +// how much body we still have to read.
  +protected int available = -1; 
  +
   protected String contentType = null;
   protected String charEncoding = null;
   protected MessageBytes serverNameMB=new MessageBytes();
  @@ -327,12 +330,26 @@
*  are available.
*/
   public void handlePostParameters() {
  - int needData=params.needContent();
  + if( didReadFormData )
  + return;
  + didReadFormData=true;
  +
  + if( ! methodMB.equalsIgnoreCase("POST") )
  + return;
  + String contentType= getContentType();
  + if (contentType == null &&
  +contentType.startsWith("application/x-www-form-urlencoded")) {
  + return;
  + }
   
  - if( needData > 0 ) {
  + int len=getContentLength();
  + int available=getAvailable();
  +
  + // read only available ( someone else may have read the content )
  + if( available > 0 ) {
try {
  - byte[] formData = new byte[needData];
  - readBody( formData, needData );
  + byte[] formData = new byte[available];
  + readBody( formData, available );
params.processData( formData );
} catch(IOException ex ) {
// XXX should we throw exception or log ?
  @@ -345,8 +362,6 @@
return params;
   }
   
  -
  -
   //  encoding/type 
   
   public String getCharacterEncoding() {
  @@ -361,6 +376,7 @@
   
   public void setContentLength( int  len ) {
this.contentLength=len;
  + available=len;
   }
   
   public int getContentLength() {
  @@ -368,6 +384,7 @@
   
MessageBytes clB=headers.getValue("content-length");
   contentLength = (clB==null || clB.isNull() ) ? -1 : clB.getInt();
  + available=contentLength;
   
return contentLength;
   }
  @@ -690,38 +707,43 @@
   return headers.names();
   }
   
  -//  Utils - facade for RequestUtil
  +//  Computed fields 
  +
   
  -/** Read request data, filling a byte[]
  +//  For adapters 
  +// This should move to an IntputBuffer - the readi

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-02-05 Thread costin

costin  01/02/05 22:24:27

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  All parameter handling code is now part of Parameters.
  The internal representation of parameters is now encapsulated,
  no external class can access the internal details.
  
  This is still the old code and representation ( hashatble of
  name-> value[] ), but a the processing has been improved and now follows the
  rules defined in the spec for merging GET/POST params and merging
  RequestDispatcher queries.
  
  It'll also simplify RequestDispatcher a lot by removing all the hacky
  code to support parameter saving/restoring.
  
  ( this started as a fix for JspInterceptor to deal with jsp_precompile,
  but it's better to do a real fix instead of a simple hack. )
  
  Revision  ChangesPath
  1.7   +285 -174  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Parameters.java   2001/01/01 00:17:24 1.6
  +++ Parameters.java   2001/02/06 06:24:26 1.7
  @@ -70,11 +70,29 @@
* @author Costin Manolache
*/
   public final class Parameters extends MultiMap {
  +// Transition: we'll use the same Hashtable( String->String[] )
  +// for the beginning. When we are sure all accesses happen through
  +// this class - we can switch to MultiMap
  +private Hashtable paramHashStringArray=new Hashtable();
  +private boolean didQueryParameters=false;
  +private boolean didReadFormData=false;
  +private boolean didMerge=false;
  +
  +MessageBytes queryMB;
  +MimeHeaders  headers;
  +
   public static final int INITIAL_SIZE=4;
   
  -private boolean isSet=false;
  -private boolean isFormBased=false;
  -
  +// Garbage-less parameter merging.
  +// In a sub-request with parameters, the new parameters
  +// will be stored in child. When a getParameter happens,
  +// the 2 are merged togheter. The child will be altered
  +// to contain the merged values - the parent is allways the
  +// original request.
  +private Parameters child=null;
  +private Parameters parent=null;
  +private Parameters currentChild=null;
  +
   /**
* 
*/
  @@ -82,30 +100,282 @@
super( INITIAL_SIZE );
   }
   
  +public void setQuery( MessageBytes queryMB ) {
  + this.queryMB=queryMB;
  +}
  +
  +public void setHeaders( MimeHeaders headers ) {
  + this.headers=headers;
  +}
  +
   public void recycle() {
super.recycle();
  - isSet=false;
  - isFormBased=false;
  + paramHashStringArray.clear();
  + didQueryParameters=false;
  + didReadFormData=false;
  + currentChild=null;
  + didMerge=false;
   }
  +
  +//  Sub-request support 
   
  -/**
  +public Parameters getCurrentSet() {
  + if( currentChild==null )
  + return this;
  + return currentChild;
  +}
  +
  +/** Create ( or reuse ) a child that will be used during a sub-request.
  + All future changes ( setting query string, adding parameters )
  + will affect the child ( the parent request is never changed ).
  + Both setters and getters will return the data from the deepest
  + child, merged with data from parents.
  +*/
  +public void push() {
  + // We maintain a linked list, that will grow to the size of the
  + // longest include chain.
  + // The list has 2 points of interest:
  + // - request.parameters() is the original request and head,
  + // - request.parameters().currentChild() is the current set.
  + // The ->child and parent<- links are preserved ( currentChild is not
  + // the last in the list )
  + 
  + // create a new element in the linked list
  + // note that we reuse the child, if any - pop will not
  + // set child to null !
  + if( currentChild.child==null ) {
  + currentChild.child=new Parameters();
  + currentChild.child.parent=currentChild;
  + } // it is not null if this object already had a child
  + // i.e. a deeper include() ( we keep it )
  +
  + // the head will be the new element.
  + currentChild=currentChild.child;
  +}
  +
  +/** Discard the last child. This happens when we return from a
  + sub-request and the parameters are locally modified.
*/
  -public boolean isEvaluated() {
  - return isSet;
  +public void pop() {
  + if( currentChild==null ) {
  + throw new RuntimeException( "Attempt to pop without a push" );
  + }
  + currentChild.recycle();
  + currentChild=currentChild.parent;
  + // don't remove the top.
  

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2000-12-31 Thread costin

costin  00/12/31 16:17:24

  Modified:.changes3.3
   src/facade22/org/apache/tomcat/facade
HttpServletRequestFacade.java
HttpSessionFacade.java Servlet22Interceptor.java
   src/share/org/apache/tomcat/context LoaderInterceptor11.java
LoaderInterceptor12.java
   src/share/org/apache/tomcat/core BaseInterceptor.java
Container.java ContextManager.java Request.java
   src/share/org/apache/tomcat/modules/session SessionId.java
SimpleSessionStore.java
   src/share/org/apache/tomcat/request
CredentialsInterceptor.java ReloadInterceptor.java
   src/share/org/apache/tomcat/util ObjectSerializer.java
   src/share/org/apache/tomcat/util/hooks Hooks.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Added:   src/share/org/apache/tomcat/core ServerSession.java
  Removed: src/share/org/apache/tomcat/session ServerSession.java
ServerSessionManager.java
  Log:
  Finish ( I hope ) refactoring of session management.
  
  - ServerSession moved to core. It's no longer final - session manager modules
  can extend and replace the functionality.
  
  - added few more properties ( for symetry with other classes in core):
  notes, context, state, facade.
  
  - Replaced the "newSessionRequest" hook with 2 other hooks: findSession
  and sessionState. This allow modules to control most aspects of session
  processing.
  
  - Servlet22Interceptor now corectly handles servlet-specific aspects of
  session management - binding events, etc. That happens for both
  expired sessions and reloading.
  
  - Small improvement in reloading: we'll set a context note with the old
  class loader, and on session reloading we replace only the objects loaded
  with the old loader. That means an object that is loaded with the main
  class loader ( like DatabaseConnection ) will be valid after reload.
  ( should this be optional ? )
  
  - SessionId will now verify if the session is valid for both cookies and
  URL rewriting ( used to be only for cookies ). It'll also call "touch" -
  SimpleSessionManager will deal only with the 2 session hooks, no more
  intervention in the mapping hooks.
  
  - The ServerManager is now part of SimpleSessionStore. A session
  plugin is formed from a session manager and a tomcat 3.3 interceptor.
  
  Another small change: if the module implements "registerHooks", it'll
  be allowed to register the hooks itself, instead of using the automated
  code in Hooks. That means it can insert itself in front, end or after
  another module ( apache 2.0 style ) - by default the modules are inserted
  automatically at the end.
  
  Revision  ChangesPath
  1.5   +5 -0  jakarta-tomcat/changes3.3
  
  Index: changes3.3
  ===
  RCS file: /home/cvs/jakarta-tomcat/changes3.3,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- changes3.32000/12/27 19:52:49 1.4
  +++ changes3.32001/01/01 00:17:22 1.5
  @@ -1,5 +1,10 @@
    CORE 
   
  +- reloading: objects loaded with the parent class loader will not be touched.
  +( faster, fewer problems with non-serializable objects )
  +
  +- better session plugability
  +
   - improved authentication - a bit of performance and more flexibility
(CredentialInterceptor)
   
  
  
  
  1.16  +0 -1  
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- HttpServletRequestFacade.java 2000/12/30 07:54:10 1.15
  +++ HttpServletRequestFacade.java 2001/01/01 00:17:22 1.16
  @@ -64,7 +64,6 @@
   import org.apache.tomcat.util.http.*;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.facade.*;
  -import org.apache.tomcat.session.*;
   import java.io.*;
   import java.net.*;
   import java.security.*;
  
  
  
  1.6   +3 -2  
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpSessionFacade.java
  
  Index: HttpSessionFacade.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpSessionFacade.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HttpSessionFacade.java2000/12/01 19:59:21 1.5
  +++ HttpSessionFacade.java2001/01/01 00:17:22 1.6
  @@ -61,7 +61,6 @@
   package org.apache.tomcat.facade;
   
   import org.apache.to

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2000-12-26 Thread costin

costin  00/12/26 15:35:38

  Modified:src/share/org/apache/tomcat/core Response.java
   src/share/org/apache/tomcat/modules/server Ajp12.java
Ajp13.java Ajp13Interceptor.java
JNIConnectionHandler.java
   src/share/org/apache/tomcat/request AccessInterceptor.java
InvokerInterceptor.java ReloadInterceptor.java
StaticInterceptor.java
   src/share/org/apache/tomcat/startup EmbededTomcat.java
   src/share/org/apache/tomcat/util ByteChunk.java
CharChunk.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  small fixes, updates for the changes in Request and ContextManager
  
  Revision  ChangesPath
  1.44  +2 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Response.java 2000/12/05 14:02:41 1.43
  +++ Response.java 2000/12/26 23:35:33 1.44
  @@ -339,13 +339,14 @@
notifyEndHeaders();
   }
   
  +// XXX XXX 
   /** Signal that we're done with the headers, and body will follow.
*  Any implementation needs to notify ContextManager, to allow
*  interceptors to fix headers.
*/
   public void notifyEndHeaders() throws IOException {
commited=true;
  - if(request.getProtocol()==null) // HTTP/0.9 
  + if(request.protocol().isNull()) // HTTP/0.9 
return;
   
// let CM notify interceptors and give a chance to fix
  
  
  
  1.10  +1 -2  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp12.java
  
  Index: Ajp12.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp12.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Ajp12.java2000/12/17 02:37:55 1.9
  +++ Ajp12.java2000/12/26 23:35:34 1.10
  @@ -140,8 +140,7 @@
   
//Apache document root
dummy = readString(ajpin, null);   
  - req.setPathInfo( readString(ajpin, null));   
  - //Apache parsed path-translated XXX Bug in mod_jserv !
  + req.pathInfo().setString( readString(ajpin, null));
 //Apache parsed path-translated XXX Bug in mod_jserv !
dummy = readString(ajpin, null);
req.queryString().setString( readString(ajpin, null));  
req.setRemoteAddr(readString(ajpin, ""));
  
  
  
  1.7   +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java
  
  Index: Ajp13.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Ajp13.java2000/12/05 06:30:15 1.6
  +++ Ajp13.java2000/12/26 23:35:34 1.7
  @@ -249,7 +249,7 @@
   byte methodCode = msg.getByte();
   req.method().setString( methodTransArray[(int)methodCode - 1] );
   
  -req.setProtocol(msg.getString());
  +req.protocol().setString( msg.getString());
   req.requestURI().setString( msg.getString());
   
   req.setRemoteAddr(  msg.getString());
  
  
  
  1.5   +4 -4  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13Interceptor.java
  
  Index: Ajp13Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13Interceptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Ajp13Interceptor.java 2000/11/30 07:36:03 1.4
  +++ Ajp13Interceptor.java 2000/12/26 23:35:34 1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13Interceptor.java,v
 1.4 2000/11/30 07:36:03 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/11/30 07:36:03 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13Interceptor.java,v
 1.5 2000/12/26 23:35:34 costin Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/12/26 23:35:34 $
*
* 
*
  @@ -254,7 +254,7 @@
   {
   super.endHeaders();
   
  -if (request.getProtocol() == null) {
  +if (request.protocol().isNull()) {
   return;
  

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2000-12-02 Thread costin

costin  00/12/02 00:27:05

  Modified:src/share/org/apache/tomcat/core BaseInterceptor.java
ContextManager.java
   src/share/org/apache/tomcat/request ReloadInterceptor.java
   src/share/org/apache/tomcat/util/collections MultiMap.java
   src/share/org/apache/tomcat/util/depend DependManager.java
   src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  - Fixed the documentation of ContextManager ( or started to ), fixed
  the shutdown. Thanks Larry, I think now is better. I'll continue to
  fix the code to match the documentation.
  
  - fixed the compilation for jdk1.1.7 ( the compiler is buggy )
  
  - make sure the "JVM is broken" is displayed only once, no need
  to see it for every request.
  
  Revision  ChangesPath
  1.26  +5 -0  
jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- BaseInterceptor.java  2000/11/02 21:24:42 1.25
  +++ BaseInterceptor.java  2000/12/02 08:26:45 1.26
  @@ -247,6 +247,9 @@
* 
*  WebXmlReader needs to be the first interceptor in
*  the contextInit chain.
  + *
  + *  @exception If the interceptor throws exception the context will 
  + * not be initialized ( state==NEW or ADDED or DISABLED ).
*/
   public void contextInit(Context ctx)
throws TomcatException
  @@ -307,6 +310,8 @@
   }
   
   /** Called when the ContextManger is started
  + *  @exception TomcatException The server will not start if any exception is 
thrown by
  + *  engineInit
*/
   public void engineInit(ContextManager cm)
throws TomcatException
  
  
  
  1.153 +151 -94   
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.152
  retrieving revision 1.153
  diff -u -r1.152 -r1.153
  --- ContextManager.java   2000/12/01 17:42:51 1.152
  +++ ContextManager.java   2000/12/02 08:26:47 1.153
  @@ -90,76 +90,91 @@
 One application may try to embed multiple ( distinct ) servlet containers -
 this feature hasn't been tested or used

  - 
  -   Expected startup order:
  +   Startup
   
  -  1. Create ContextManager
  +  1. Create ContextManager.
   
  -  2. Set settable properties for ContextManager ( home, debug, etc)
  +  2. Set properties for ContextManager ( home, debug, etc).
   
  -  3. Add global Interceptors
  +  3. Add global Interceptors.
   
 4. You may create, set and add Contexts. NO HOOKS ARE CALLED.
  +  This adds a lot of complexity to the code - but allow
  +  the server to have an initial set of contexts when it starts.
  +  More contexts can be added after startup.
 
  -  5. Call init(). At this stage engineInit() callback will be
  - called for all global interceptors.
  - - DefaultCMSetter ( or a replacement ) must be the first in
  - the chain and will adjust the paths and set defaults for
  - all unset properties.
  - - AutoSetup and other interceptors can automatically add/set
  - more properties and make other calls.
  +  5. init() At this stage engineInit() callback will be
  + called for all global interceptors. 
   
  - During engineInit() a number of Contexts are created and
  + During engineInit() a number of Contexts can be created and
added to the server. No addContext() callback is called until
  - the last engineInit() returns. ( XXX do we need this restriction ?)
  + the last engineInit() returns. Interceptors can also change the
  + state of the server ( change properites, add other interceptors,
  + etc)
   
  -  XXX I'n not sure about contextInit and about anything below.
  + After this call the server will be in INITIALIZED state.
  + No callback other than engineInit  can be called before the server
  + enters this state.
   
  -  x. Server will move to INITIALIZED state. No callback other than engineInit
  - can be called before the server enters this state.
  +  6. init() will also call the addContext() hook for all contexts
  + that were added during engineInit or before init() was called.
  + More contexts can be added after init() and before start().
   
  -  x. addContext() callbacks will be called for each context.
  - After init you may add more contexts, and addContext() callback
  - will be called (since the server is initialized )
  + InitContext will have no effect before the se