costin 02/04/09 10:23:49 Modified: http11/src/java/org/apache/coyote/http11 Http11Processor.java Log: If host header is not set, use the local socket to set the local port and hostname. Remy - I'm not sure if this is correct, but I see no other way to pass this info ( I could add a callback - but this is needed in most calls ). If there is any particular reason to keep port and localhost unset I'll rollback and add the callback. ( this used to be in the 3.3-specific code, and is needed to construct redirects, etc ) Revision Changes Path 1.20 +13 -9 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java Index: Http11Processor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- Http11Processor.java 9 Apr 2002 09:27:12 -0000 1.19 +++ Http11Processor.java 9 Apr 2002 17:23:49 -0000 1.20 @@ -65,6 +65,7 @@ import java.io.IOException; import java.io.OutputStream; import java.net.Socket; +import java.net.InetAddress; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.buf.MessageBytes; @@ -345,7 +346,6 @@ int keepAliveLeft = maxKeepAliveRequests; while (started && !error && keepAlive) { - try { inputBuffer.parseRequestLine(); inputBuffer.parseHeaders(); @@ -720,19 +720,22 @@ /** * Parse host. */ - public static void parseHost(Request req) + public void parseHost(Request req) throws IOException { MessageBytes valueMB = req.getMimeHeaders().getValue("host"); - // 3.3 version. In 4.0 it is extracted from the host header. - // XXX I would rather trust the socket... - //serverPort = socket.getLocalPort(); + + // Default is what the socket tells us. Overriden if a host is found/parsed + req.setServerPort( socket.getLocalPort() ); + InetAddress localAddress = socket.getLocalAddress(); + ByteChunk valueBC = null; if (valueMB == null) { // That was in the 3.3 connector. 4.0 let it unset. - //// InetAddress localAddress = socket.getLocalAddress(); - ////localHost = localAddress.getHostName(); - // serverNameMB.setString( getLocalHost() ); + // Setting the socket-related fields. The adapter doesn't know about + // socket. + req.setLocalHost( localAddress.getHostName() ); + req.serverName().setString( localAddress.getHostName() ); return; } valueBC = valueMB.getByteChunk(); @@ -750,7 +753,8 @@ } if (colonPos < 0) { - req.setServerPort(80); + //The info from socket is usually acurate + // req.setServerPort(80); req.serverName().setBytes( valueB, valueS, valueL); } else { req.serverName().setBytes( valueB, valueS, colonPos);
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>