costin 01/01/28 13:46:01
Modified: src/admin/test test.jsp
src/native/mod_jk/apache1.3 mod_jk.c
src/share/org/apache/tomcat/modules/generators
StaticInterceptor.java
src/share/org/apache/tomcat/modules/server Ajp12.java
src/share/org/apache/tomcat/util/test Body.java GTest.java
src/tests/webpages/WEB-INF test-tomcat.xml
Log:
Fix in mod_jk.c ( should resolve at least some of the failures
on Apache ) - we need to check Apache2.0 module too.
- send the "right" hostname and port ( uncomment the println to see
what's generated in the other cases - at least of 1.3.12 this is the
only combination that seems to work )
- This should fix "Location" problems with Apache
StaticInterceptor:
- more consistency with Apache, use 301 instead of 302 and do a redirect for
directories if the uri doesn't end in "/"
-Ajp12 - read the protocol from the server ( it was http/1.0 only ). Even
if currently tomcat implements only 1.0, we should report the protocol
of the real server - i.e. 1.1.
- added few comments in test-tomcat.xml
test.jsp:
- fill port and host from the request data ( if you access test.jsp
using Apache port - no need to change )
- added "comments" for failed tests. Gtest now supports a
<comment>body</comment> to allow more descriptive data ( description
is very limited )
Revision Changes Path
1.8 +9 -3 jakarta-tomcat/src/admin/test/test.jsp
Index: test.jsp
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/admin/test/test.jsp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- test.jsp 2001/01/28 19:18:37 1.7
+++ test.jsp 2001/01/28 21:46:00 1.8
@@ -26,9 +26,12 @@
<br>
Debug: <input type="checkbox" name="debug" value="10"><br>
-Port: <input type="input" name="port" value="8080"><br>
-Host: <input type="input" name="host" value="127.0.0.1"><br>
-Expected protocol: <input type="input" name="server.proto" value="HTTP/1.0">
+Port: <input type="input" name="port" value="<%= request.getServerPort() %>">
+<br>
+Host: <input type="input" name="host" value="<%= request.getServerName() %>">
+<br>
+Expected protocol: <input type="input" name="server.proto"
+ value="<%= request.getProtocol() %>">
( use when testing Apache - tomcat3.x returns HTTP/1.0 ) <br>
<input type="submit">
</form>
@@ -76,6 +79,9 @@
<pre>
<%= failures.getHttpClient().getFullRequest() %>
</pre>
+<b>Comments: </b>
+ <%= failures.getComment() %>
+<br>
<b>Message: </b>
<pre>
<%= failures.getMatcher().getMessage() %>
1.3 +24 -2 jakarta-tomcat/src/native/mod_jk/apache1.3/mod_jk.c
Index: mod_jk.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/apache1.3/mod_jk.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mod_jk.c 2000/11/10 18:48:50 1.2
+++ mod_jk.c 2001/01/28 21:46:00 1.3
@@ -351,8 +351,30 @@
s->remote_host = NULL_FOR_EMPTY(s->remote_host);
s->remote_addr = NULL_FOR_EMPTY(r->connection->remote_ip);
- s->server_name = (char *)(r->hostname ? r->hostname :
r->server->server_hostname);
- s->server_port = r->server->port;
+ /* Wrong: s->server_name = (char *)ap_get_server_name( r ); */
+ s->server_name= (char *)(r->hostname ? r->hostname :
+ r->server->server_hostname);
+
+
+ s->server_port= htons( r->connection->local_addr.sin_port );
+ /* Wrong: s->server_port = r->server->port; */
+
+
+ /* Winners: htons( r->connection->local_addr.sin_port )
+ (r->hostname ? r->hostname :
+ r->server->server_hostname),
+ */
+ /* printf( "Port %u %u %u %s %s %s %d %d \n",
+ ap_get_server_port( r ),
+ htons( r->connection->local_addr.sin_port ),
+ ntohs( r->connection->local_addr.sin_port ),
+ ap_get_server_name( r ),
+ (r->hostname ? r->hostname : r->server->server_hostname),
+ r->hostname,
+ r->connection->base_server->port,
+ r->server->port
+ );
+ */
s->server_software = (char *)ap_get_server_version();
s->method = (char *)r->method;
1.3 +10 -1
jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java
Index: StaticInterceptor.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StaticInterceptor.java 2001/01/01 02:07:24 1.2
+++ StaticInterceptor.java 2001/01/28 21:46:00 1.3
@@ -167,6 +167,15 @@
return 0;
}
+ // consistent with Apache
+ if( ! requestURI.endsWith("/") ) {
+ String redirectURI= requestURI + "/";
+ req.setAttribute("javax.servlet.error.message",
+ redirectURI);
+ if( debug > 0) log( "Redirect " + redirectURI );
+ return 301;
+ }
+
// Send redirect to the welcome file.
// This is consistent with other web servers and avoids
// gray areas in the spec - if the welcome file is a jsp,
@@ -179,7 +188,7 @@
req.setAttribute("javax.servlet.error.message",
redirectURI);
if( debug > 0) log( "Redirect " + redirectURI );
- return 302;
+ return 301;
}
private static String concatPath( String s1, String s2 ) {
1.12 +17 -4
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Ajp12.java 2000/12/29 19:59:19 1.11
+++ Ajp12.java 2001/01/28 21:46:00 1.12
@@ -142,7 +142,8 @@
//Server hostname
req.serverName().setString(readString(ajpin, null) );
-
+ //System.out.println("XXX hostname: " + req.serverName());
+
//Apache document root
dummy = readString(ajpin, null);
req.pathInfo().setString( readString(ajpin, null));
//Apache parsed path-translated XXX Bug in mod_jserv !!!!!
@@ -155,7 +156,9 @@
else req.setRemoteUser( readString(ajpin, null));
req.setAuthType(readString(ajpin, null));
//remote port
- dummy = readString(ajpin, null);
+ dummy = readString(ajpin, null);
+ // System.out.println("XXX rport " + dummy );
+
req.method().setString( readString(ajpin, null));
req.requestURI().setString( readString(ajpin, ""));
@@ -172,13 +175,20 @@
int serverPort=80;
try {
- serverPort= Integer.parseInt(readString(ajpin,"80"));
+ String p=readString(ajpin, null);
+ //System.out.println("XXX p " + p);
+ if(p==null ) p="80";
+ serverPort= Integer.parseInt(p);
} catch (Exception any) {
+ any.printStackTrace();
}
req.setServerPort( serverPort );
+ // System.out.println("XXX port: " + req.getServerPort());
//server protocol
- dummy = readString(ajpin, "");
+ String proto=readString(ajpin,null);
+ if( proto==null ) proto="HTTP/1.0";
+ req.protocol().setString (proto);
//server signature
dummy = readString(ajpin, "");
//server software
@@ -223,6 +233,9 @@
case 3: // Header
token1 = readString(ajpin, null);
token2 = readString(ajpin, "");
+// if( "Host".equalsIgnoreCase( token1 )) {
+// System.out.println("XXX Host: " + token2);
+// }
req.getMimeHeaders().addValue(token1).setString(token2);
break;
1.2 +1 -0 jakarta-tomcat/src/share/org/apache/tomcat/util/test/Body.java
Index: Body.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/Body.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Body.java 2001/01/20 19:42:09 1.1
+++ Body.java 2001/01/28 21:46:01 1.2
@@ -63,6 +63,7 @@
import java.util.*;
import java.net.*;
+//XXX rename it to Text
/**
* Part of GTest. Simple representation of a request/response body.
1.6 +10 -0 jakarta-tomcat/src/share/org/apache/tomcat/util/test/GTest.java
Index: GTest.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/GTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GTest.java 2001/01/22 16:42:12 1.5
+++ GTest.java 2001/01/28 21:46:01 1.6
@@ -87,6 +87,7 @@
HttpClient httpClient=new HttpClient();
DefaultMatcher matcher=new DefaultMatcher();
+ Body comment=null;
String description="No description";
@@ -175,6 +176,11 @@
public void addDefaultMatcher( DefaultMatcher m ) {
matcher=m;
}
+
+ public Body createComment() {
+ comment=new Body();
+ return comment;
+ }
// -------------------- Getters --------------------
public HttpClient getHttpClient() {
@@ -183,6 +189,10 @@
public DefaultMatcher getMatcher() {
return matcher;
+ }
+
+ public String getComment() {
+ return comment.getText();
}
// -------------------- Local properties --------------------
1.11 +15 -14 jakarta-tomcat/src/tests/webpages/WEB-INF/test-tomcat.xml
Index: test-tomcat.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/tests/webpages/WEB-INF/test-tomcat.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- test-tomcat.xml 2001/01/28 19:58:21 1.10
+++ test-tomcat.xml 2001/01/28 21:46:01 1.11
@@ -16,7 +16,7 @@
early tests.
-->
- <property name="revision" value="$Revision: 1.10 $" />
+ <property name="revision" value="$Revision: 1.11 $" />
<property name="host" value="127.0.0.1" />
<property name="port" value="8080" />
<property name="outputType" value="text" />
@@ -36,6 +36,8 @@
classname="org.apache.tomcat.util.test.Body" />
<taskdef name="defaultMatcher"
classname="org.apache.tomcat.util.test.DefaultMatcher" />
+ <taskdef name="comment"
+ classname="org.apache.tomcat.util.test.Body" />
<taskdef name="gtestDefaults"
classname="org.apache.tomcat.util.test.TestDefaults" />
@@ -78,11 +80,10 @@
<target name="file-tomcat" depends="init,file">
- <!-- return code is 301 for Apache, 302 for tomcat -->
- <gtest description="Welcome File Test1 - directory access"
+ <gtest description="Get a directory - expect redirect"
request="GET /test/welcome HTTP/1.0"
expectHeaders="Location:/welcome/"
- returnCode="${http.protocol} 30" />
+ returnCode="${http.protocol} 301" />
<!-- Difference in behavior between Apache and tomcat
XXX IMHO the tomcat behavior is OK, but it would be a good idea
@@ -96,16 +97,11 @@
bug, but we should fix it anyway -->
<gtest description="Welcome File Test3"
request="GET /test/welcome/ HTTP/1.0"
- returnCode="${http.protocol} 302" />
+ returnCode="${http.protocol} 301" />
<!-- goldenFile="${gdir}/movedwelcome.txt" />-->
</target>
<target name="file-apache" depends="init,file">
- <gtest description="Welcome File Test1"
- request="GET /test/welcome HTTP/1.0"
- expectHeaders="Location:/welcome/"
- returnCode="${http.protocol} 301" />
-
<gtest description="Welcome File Test2"
request="GET /test/binaries HTTP/1.0"
returnCode="${http.protocol} 301" />
@@ -658,10 +654,15 @@
responseMatch="Servlet: Servlet1"
/>
- <gtest description="/foo/bar/index.bop : 1.0 : 200"
- request="GET /test/foo/bar/index.bop HTTP/1.0"
- responseMatch="Servlet: Servlet1"
- />
+ <gtest request="GET /test/foo/bar/index.bop HTTP/1.0"
+ responseMatch="Servlet: Servlet1" >
+ <comment>
+Test if web.xml mappings are respected - /foo/bar is mapped to servlet1.
+Apache will probably fail ( special configuration is required to
+do all mapping - this is a known problem, to be resolved by integrating
+mod_webapp into mod_jk )
+ </comment>
+ </gtest>
<gtest description="/baz : 1.0 : 200"
request="GET /test/baz HTTP/1.0"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]