seguin 01/06/25 09:00:43
Modified: jk/java/org/apache/ajp Ajp13.java AjpRequest.java
jk/java/org/apache/ajp/tomcat4 Ajp13Request.java
Log:
changed AjpRequest so that it extends org.apache.tomcat.util.http.BaseRequest.
NOTE: not sure if this is the *right thing* -- perhaps AjpRequest should wrap
BaseRequest.
guess we'll figure that out later :)
Revision Changes Path
1.8 +26 -23 jakarta-tomcat-connectors/jk/java/org/apache/ajp/Ajp13.java
Index: Ajp13.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/Ajp13.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Ajp13.java 2001/06/24 21:17:49 1.7
+++ Ajp13.java 2001/06/25 16:00:38 1.8
@@ -316,20 +316,20 @@
// Translate the HTTP method code to a String.
byte methodCode = msg.getByte();
- req.method.setString( methodTransArray[(int)methodCode - 1] );
+ req.method().setString(methodTransArray[(int)methodCode - 1]);
- msg.getMessageBytes(req.protocol);
- msg.getMessageBytes(req.requestURI);
+ msg.getMessageBytes(req.protocol());
+ msg.getMessageBytes(req.requestURI());
- msg.getMessageBytes(req.remoteAddr);
- msg.getMessageBytes(req.remoteHost);
- msg.getMessageBytes(req.serverName);
- req.serverPort = msg.getInt();
+ msg.getMessageBytes(req.remoteAddr());
+ msg.getMessageBytes(req.remoteHost());
+ msg.getMessageBytes(req.serverName());
+ req.setServerPort(msg.getInt());
isSSL = msg.getBool();
// Decode headers
- MimeHeaders headers = req.headers;
+ MimeHeaders headers = req.headers();
int hCount = msg.getInt();
for(int i = 0 ; i < hCount ; i++) {
String hName = null;
@@ -345,23 +345,26 @@
if(0xA000 == isc) {
msg.getInt(); // To advance the read position
hName = headerTransArray[hId - 1];
- vMB= headers.addValue( hName );
+ vMB= headers.addValue(hName);
} else {
// XXX Not very elegant
- vMB=msg.addHeader( headers );
- if( vMB==null) return 500; // wrong packet
+ vMB = msg.addHeader(headers);
+ if (vMB == null) {
+ return 500; // wrong packet
+ }
}
msg.getMessageBytes(vMB);
// set content length, if this is it...
if (hId == SC_REQ_CONTENT_LENGTH) {
- req.contentLength = (vMB == null) ? -1 : vMB.getInt();
+ int contentLength = (vMB == null) ? -1 : vMB.getInt();
+ req.setContentLength(contentLength);
} else if (hId == SC_REQ_CONTENT_TYPE) {
ByteChunk bchunk = vMB.getByteChunk();
- req.contentType.setBytes(bchunk.getBytes(),
- bchunk.getOffset(),
- bchunk.getLength());
+ req.contentType().setBytes(bchunk.getBytes(),
+ bchunk.getOffset(),
+ bchunk.getLength());
}
}
@@ -377,19 +380,19 @@
break;
case SC_A_REMOTE_USER :
- msg.getMessageBytes(req.remoteUser);
+ msg.getMessageBytes(req.remoteUser());
break;
case SC_A_AUTH_TYPE :
- msg.getMessageBytes(req.authType);
+ msg.getMessageBytes(req.authType());
break;
case SC_A_QUERY_STRING :
- msg.getMessageBytes(req.queryString);
+ msg.getMessageBytes(req.queryString());
break;
case SC_A_JVM_ROUTE :
- msg.getMessageBytes(req.jvmRoute);
+ msg.getMessageBytes(req.jvmRoute());
break;
case SC_A_SSL_CERT :
@@ -424,16 +427,16 @@
}
if(isSSL) {
- req.scheme = req.SCHEME_HTTPS;
- req.secure = true;
+ req.setScheme(req.SCHEME_HTTPS);
+ req.setSecure(true);
}
// set cookies on request now that we have all headers
- req.cookies.setHeaders(req.headers);
+ req.cookies().setHeaders(req.headers());
// Check to see if there should be a body packet coming along
// immediately after
- if(req.contentLength > 0) {
+ if(req.getContentLength() > 0) {
/* Read present data */
int err = receive(inBuf);
1.5 +5 -232 jakarta-tomcat-connectors/jk/java/org/apache/ajp/AjpRequest.java
Index: AjpRequest.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/AjpRequest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AjpRequest.java 2001/06/24 22:29:01 1.4
+++ AjpRequest.java 2001/06/25 16:00:39 1.5
@@ -61,13 +61,8 @@
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Iterator;
-
import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.http.Cookies;
+import org.apache.tomcat.util.http.BaseRequest;
/**
* Encapsulates an ajp request.
@@ -76,258 +71,36 @@
* <code>AjpRequest</code> that can then be used by an adaptor
* and/or connector to process the request.
*/
-public class AjpRequest {
-
- // scheme constants
- public static final String SCHEME_HTTP = "http";
- public static final String SCHEME_HTTPS = "https";
-
- // an empty iterator
- private final static Iterator emptyItr = new LinkedList().iterator();
+public class AjpRequest extends BaseRequest {
- // request attributes
- MessageBytes method = new MessageBytes();
- MessageBytes protocol = new MessageBytes();
- MessageBytes requestURI = new MessageBytes();
- MessageBytes remoteAddr = new MessageBytes();
- MessageBytes remoteHost = new MessageBytes();
- MessageBytes serverName = new MessageBytes();
- int serverPort = 80;
- MessageBytes remoteUser = new MessageBytes();
- MessageBytes authType = new MessageBytes();
- MessageBytes queryString = new MessageBytes();
MessageBytes jvmRoute = new MessageBytes();
- String scheme = SCHEME_HTTP;
- boolean secure = false;
- int contentLength = 0;
- MessageBytes contentType = new MessageBytes();
- MimeHeaders headers = new MimeHeaders();
- Cookies cookies = new Cookies();
- HashMap attributes = new HashMap();
/**
* Recycles this object and readies it further use.
*/
public void recycle() {
- method.recycle();
- protocol.recycle();
- requestURI.recycle();
- remoteAddr.recycle();
- remoteHost.recycle();
- serverName.recycle();
- serverPort = 80;
- remoteUser.recycle();
- authType.recycle();
- queryString.recycle();
+ super.recycle();
jvmRoute.recycle();
- scheme = SCHEME_HTTP;
- secure = false;
- contentLength = 0;
- contentType.recycle();
- headers.recycle();
- cookies.recycle();
- attributes.clear();
- }
-
- /**
- * Get the method.
- * @return the method
- */
- public MessageBytes getMethod() {
- return method;
- }
-
- /**
- * Get the protocol
- * @return the protocol
- */
- public MessageBytes getProtocol() {
- return protocol;
- }
-
- /**
- * Get the request uri
- * @return the request uri
- */
- public MessageBytes getRequestURI() {
- return requestURI;
- }
-
- /**
- * Get the remote address
- * @return the remote address
- */
- public MessageBytes getRemoteAddr() {
- return remoteAddr;
- }
-
- /**
- * Get the remote host
- * @return the remote host
- */
- public MessageBytes getRemoteHost() {
- return remoteHost;
- }
-
- /**
- * Get the server name
- * @return the server name
- */
- public MessageBytes getServerName() {
- return serverName;
- }
-
- /**
- * Get the server port
- * @return the server port
- */
- public int getServerPort() {
- return serverPort;
- }
-
- public void setServerPort( int s ) {
- serverPort=s;
- }
-
- /**
- * Get the remote user
- * @return the remote user
- */
- public MessageBytes getRemoteUser() {
- return remoteUser;
- }
-
- /**
- * Get the auth type
- * @return the auth type
- */
- public MessageBytes getAuthType() {
- return authType;
}
/**
- * Get the query string
- * @return the query string
- */
- public MessageBytes getQueryString() {
- return queryString;
- }
-
- /**
* Get the jvm route
* @return the jvm route
*/
- public MessageBytes getJvmRoute() {
+ public MessageBytes jvmRoute() {
return jvmRoute;
}
/**
- * Get the scheme
- * @return the scheme
- */
- public String getScheme() {
- return scheme;
- }
-
- /**
- * Get whether the request is secure or not.
- * @return <code>true</code> if the request is secure.
- */
- public boolean getSecure() {
- return secure;
- }
-
- /**
- * Get the content length
- * @return the content length
- */
- public int getContentLength() {
- return contentLength;
- }
-
- /**
- * Get the content type
- * @return the content type
- */
- public MessageBytes getContentType() {
- return contentType;
- }
-
- /**
- * Get this request's headers
- * @return request headers
- */
- public MimeHeaders getHeaders() {
- return headers;
- }
-
- /**
- * Get cookies.
- * @return request cookies.
- */
- public Cookies getCookies() {
- return cookies;
- }
-
- /**
- * Set an attribute on the request
- * @param name attribute name
- * @param value attribute value
- */
- public void setAttribute(String name, Object value) {
- if (name == null || value == null) {
- return;
- }
- attributes.put(name, value);
- }
-
- /**
- * Get an attribute on the request
- * @param name attribute name
- * @return attribute value
- */
- public Object getAttribute(String name) {
- if (name == null) {
- return null;
- }
-
- return attributes.get(name);
- }
-
- /**
- * Get iterator over attribute names
- * @return iterator over attribute names
- */
- public Iterator getAttributeNames() {
- return attributes.keySet().iterator();
- }
-
- /**
* ** SLOW ** for debugging only!
*/
public String toString() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
+ pw.print(super.toString());
pw.println("=== AjpRequest ===");
- pw.println("method = " + method.toString());
- pw.println("protocol = " + protocol.toString());
- pw.println("requestURI = " + requestURI.toString());
- pw.println("remoteAddr = " + remoteAddr.toString());
- pw.println("remoteHost = " + remoteHost.toString());
- pw.println("serverName = " + serverName.toString());
- pw.println("serverPort = " + serverPort);
- pw.println("remoteUser = " + remoteUser.toString());
- pw.println("authType = " + authType.toString());
- pw.println("queryString = " + queryString.toString());
pw.println("jvmRoute = " + jvmRoute.toString());
- pw.println("scheme = " + scheme.toString());
- pw.println("secure = " + secure);
- pw.println("contentLength = " + contentLength);
- pw.println("contentType = " + contentType);
- pw.println("attributes = " + attributes.toString());
- pw.println("headers = " + headers.toString());
- pw.println("cookies = " + cookies.toString());
return sw.toString();
}
}
1.4 +12 -12
jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/Ajp13Request.java
Index: Ajp13Request.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/Ajp13Request.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Ajp13Request.java 2001/05/16 23:23:40 1.3
+++ Ajp13Request.java 2001/06/25 16:00:41 1.4
@@ -104,31 +104,31 @@
// we're more efficient (that's the whole point of
// all of the MessageBytes in AjpRequest)
- setMethod(ajp.getMethod().toString());
- setProtocol(ajp.getProtocol().toString());
- setRequestURI(ajp.getRequestURI().toString());
- setRemoteAddr(ajp.getRemoteAddr().toString());
- setRemoteHost(ajp.getRemoteHost().toString());
- setServerName(ajp.getServerName().toString());
+ setMethod(ajp.method().toString());
+ setProtocol(ajp.protocol().toString());
+ setRequestURI(ajp.requestURI().toString());
+ setRemoteAddr(ajp.remoteAddr().toString());
+ setRemoteHost(ajp.remoteHost().toString());
+ setServerName(ajp.serverName().toString());
setServerPort(ajp.getServerPort());
- String remoteUser = ajp.getRemoteUser().toString();
+ String remoteUser = ajp.remoteUser().toString();
if (remoteUser != null) {
setUserPrincipal(new Ajp13Principal(remoteUser));
}
- setAuthType(ajp.getAuthType().toString());
- setQueryString(ajp.getQueryString().toString());
+ setAuthType(ajp.authType().toString());
+ setQueryString(ajp.queryString().toString());
setScheme(ajp.getScheme());
setSecure(ajp.getSecure());
setContentLength(ajp.getContentLength());
- String contentType = ajp.getContentType().toString();
+ String contentType = ajp.contentType().toString();
if (contentType != null) {
setContentType(contentType);
}
- MimeHeaders mheaders = ajp.getHeaders();
+ MimeHeaders mheaders = ajp.headers();
int nheaders = mheaders.size();
for (int i = 0; i < nheaders; ++i) {
MessageBytes name = mheaders.getName(i);
@@ -142,7 +142,7 @@
setAttribute(name, ajp.getAttribute(name));
}
- addCookies(ajp.getCookies());
+ addCookies(ajp.cookies());
}
// public Object getAttribute(String name) {