costin 02/04/04 14:34:46 Modified: http11/src/java/org/apache/coyote/http11 Http11Processor.java Log: Moved the parseHost method from coyote. That's another step in merging the connector code and sharing a single codebase. The Host: header is specific to http, other protocols may not need this operation. Revision Changes Path 1.12 +56 -0 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Http11Processor.java 20 Mar 2002 05:33:27 -0000 1.11 +++ Http11Processor.java 4 Apr 2002 22:34:46 -0000 1.12 @@ -69,6 +69,7 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.FastHttpDateFormat; import org.apache.tomcat.util.http.MimeHeaders; +import org.apache.tomcat.util.buf.HexUtils; import org.apache.coyote.ActionHook; import org.apache.coyote.ActionCode; @@ -322,6 +323,8 @@ // Setting up filters, and parse some request headers prepareRequest(); + parseHost(request); + if(maxKeepAliveRequests > 0 && --keepAliveLeft == 0) keepAlive=false; @@ -648,7 +651,60 @@ } + /** + * Parse host. + */ + public static 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(); + 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() ); + return; + } + valueBC = valueMB.getByteChunk(); + byte[] valueB = valueBC.getBytes(); + int valueL = valueBC.getLength(); + int valueS = valueBC.getStart(); + int colonPos = -1; + + for (int i = 0; i < valueL; i++) { + char b = (char) valueB[i + valueS]; + if (b == ':') { + colonPos = i; + break; + } + } + + if (colonPos < 0) { + req.setServerPort(80); + req.serverName().setBytes( valueB, valueS, valueL); + } else { + req.serverName().setBytes( valueB, valueS, colonPos); + int port = 0; + int mult = 1; + for (int i = valueL - 1; i > colonPos; i--) { + int charValue = HexUtils.DEC[(int) valueB[i + valueS]]; + if (charValue == -1) { + // Use the default + port=80; + break; + } + port = port + (charValue * mult); + mult = 10 * mult; + } + req.setServerPort(port); + } + } + /** * When committing the response, we have to validate the set of headers, as * well as setup the response filters.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>