pier 01/07/24 18:30:47 Modified: webapp/java WarpConfigurationHandler.java WarpConnection.java WarpPacket.java WarpRequest.java WarpRequestHandler.java WarpResponse.java Log: Trimming lines and expanding tabs. Revision Changes Path 1.10 +6 -6 jakarta-tomcat-connectors/webapp/java/WarpConfigurationHandler.java Index: WarpConfigurationHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpConfigurationHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WarpConfigurationHandler.java 2001/07/19 23:36:56 1.9 +++ WarpConfigurationHandler.java 2001/07/25 01:30:46 1.10 @@ -90,9 +90,9 @@ connection.send(packet); // Loop for configuration packets - while (true) { + while (true) { connection.recv(packet); - + switch (packet.getType()) { case Constants.TYPE_CONF_DEPLOY: { @@ -103,7 +103,7 @@ Context context=null; packet.reset(); - if (Constants.DEBUG) + if (Constants.DEBUG) logger.log("Deploying web application \""+appl+"\" "+ "under <http://"+host+":"+port+path+">"); try { @@ -151,9 +151,9 @@ return(false); } } - } + } } - + /** Deploy a web application */ private Context deploy(WarpConnection connection, WarpLogger logger, String applName, String hostName, String applPath) @@ -178,7 +178,7 @@ } // TODO: Set up mapping mechanism for performance - + if (applPath.endsWith("/")) applPath=applPath.substring(0,applPath.length()-1); 1.18 +2 -2 jakarta-tomcat-connectors/webapp/java/WarpConnection.java Index: WarpConnection.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpConnection.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WarpConnection.java 2001/07/20 02:31:07 1.17 +++ WarpConnection.java 2001/07/25 01:30:46 1.18 @@ -244,13 +244,13 @@ int ret=0; while (true) { ret=this.input.read(packet.buffer,off,packet.size-off); - if (ret==-1) + if (ret==-1) throw new IOException("Premature packet payload end"); off+=ret; if(off==packet.size) break; } } - + if (Constants.DEBUG) { String typ=Integer.toHexString(packet.getType()); logger.debug("<< TYPE="+typ+" LENGTH="+packet.size); 1.13 +1 -1 jakarta-tomcat-connectors/webapp/java/WarpPacket.java Index: WarpPacket.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpPacket.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- WarpPacket.java 2001/07/19 23:45:30 1.12 +++ WarpPacket.java 2001/07/25 01:30:46 1.13 @@ -223,7 +223,7 @@ throw new RuntimeException("Unsupported encoding UTF-8"); } } - + public String dump() { StringBuffer buf=new StringBuffer("DATA="); for (int x=0; x<this.size; x++) { 1.8 +3 -3 jakarta-tomcat-connectors/webapp/java/WarpRequest.java Index: WarpRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpRequest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WarpRequest.java 2001/07/20 02:32:12 1.7 +++ WarpRequest.java 2001/07/25 01:30:46 1.8 @@ -62,15 +62,15 @@ public class WarpRequest extends HttpRequestBase { private Host host=null; - + public WarpRequest() { super(); } - + public void setHost(Host host) { this.host=host; } - + public Host getHost() { return(this.host); } 1.11 +4 -4 jakarta-tomcat-connectors/webapp/java/WarpRequestHandler.java Index: WarpRequestHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpRequestHandler.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WarpRequestHandler.java 2001/07/20 02:33:52 1.10 +++ WarpRequestHandler.java 2001/07/25 01:30:47 1.11 @@ -93,9 +93,9 @@ connection.send(packet); // Loop for configuration packets - while (true) { + while (true) { connection.recv(packet); - + switch (packet.getType()) { case Constants.TYPE_REQ_INIT: { int id=packet.readInteger(); @@ -136,7 +136,7 @@ if (clen>0) request.setContentLength(clen); break; } - + case Constants.TYPE_REQ_SCHEME: { String schm=packet.readString(); if (Constants.DEBUG) @@ -178,7 +178,7 @@ logger.debug("Request has been processed"); break; } - + default: { String msg="Invalid packet "+packet.getType(); logger.log(msg); 1.7 +58 -58 jakarta-tomcat-connectors/webapp/java/WarpResponse.java Index: WarpResponse.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpResponse.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WarpResponse.java 2001/07/20 02:34:41 1.6 +++ WarpResponse.java 2001/07/25 01:30:47 1.7 @@ -90,7 +90,7 @@ private WarpPacket packet; /** The connection to which we are associated */ private WarpConnection connection; - + /** * Create a new instance of a <code>WarpResponse</code>. */ @@ -119,7 +119,7 @@ public void setPacket(WarpPacket packet) { this.packet=packet; } - + /** * Return the <code>WarpPacket</code> instance used to process headers. */ @@ -156,12 +156,12 @@ * Send the HTTP response headers, if this has not already occurred. */ protected void sendHeaders() throws IOException { - if (isCommitted()) return; + if (isCommitted()) return; if ("HTTP/0.9".equals(request.getRequest().getProtocol())) { committed = true; return; } - + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_STATUS); this.packet.writeString(request.getRequest().getProtocol()); @@ -169,83 +169,83 @@ this.packet.writeString(message); this.connection.send(this.packet); - if (getContentType() != null) { - this.packet.reset(); + if (getContentType() != null) { + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_HEADER); this.packet.writeString("Content-Type"); this.packet.writeString(getContentType()); this.connection.send(this.packet); - } - if (getContentLength() >= 0) { - this.packet.reset(); + } + if (getContentLength() >= 0) { + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_HEADER); this.packet.writeString("Content-Length"); this.packet.writeString(Integer.toString(getContentLength())); this.connection.send(this.packet); - } - - synchronized (headers) { - Iterator names = headers.keySet().iterator(); - while (names.hasNext()) { - String name = (String) names.next(); - ArrayList values = (ArrayList) headers.get(name); - Iterator items = values.iterator(); - while (items.hasNext()) { - String value = (String) items.next(); - this.packet.reset(); + } + + synchronized (headers) { + Iterator names = headers.keySet().iterator(); + while (names.hasNext()) { + String name = (String) names.next(); + ArrayList values = (ArrayList) headers.get(name); + Iterator items = values.iterator(); + while (items.hasNext()) { + String value = (String) items.next(); + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_HEADER); this.packet.writeString(name); this.packet.writeString(value); this.connection.send(this.packet); - } - } - } - - // Add the session ID cookie if necessary - HttpServletRequest hreq = (HttpServletRequest) request.getRequest(); - HttpSession session = hreq.getSession(false); - - if ((session != null) && session.isNew() && (getContext() != null) + } + } + } + + // Add the session ID cookie if necessary + HttpServletRequest hreq = (HttpServletRequest) request.getRequest(); + HttpSession session = hreq.getSession(false); + + if ((session != null) && session.isNew() && (getContext() != null) && getContext().getCookies()) { - Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME, - session.getId()); - cookie.setMaxAge(-1); - String contextPath = null; + Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME, + session.getId()); + cookie.setMaxAge(-1); + String contextPath = null; if (context != null) contextPath = context.getPath(); - if ((contextPath != null) && (contextPath.length() > 0)) - cookie.setPath(contextPath); - else - cookie.setPath("/"); - if (hreq.isSecure()) - cookie.setSecure(true); - addCookie(cookie); - } - - // Send all specified cookies (if any) - synchronized (cookies) { - Iterator items = cookies.iterator(); + if ((contextPath != null) && (contextPath.length() > 0)) + cookie.setPath(contextPath); + else + cookie.setPath("/"); + if (hreq.isSecure()) + cookie.setSecure(true); + addCookie(cookie); + } + + // Send all specified cookies (if any) + synchronized (cookies) { + Iterator items = cookies.iterator(); while (items.hasNext()) { - Cookie cookie = (Cookie) items.next(); - String name=CookieTools.getCookieHeaderName(cookie); - StringBuffer value=new StringBuffer(); - CookieTools.getCookieHeaderValue(cookie,value); - this.packet.reset(); + Cookie cookie = (Cookie) items.next(); + String name=CookieTools.getCookieHeaderName(cookie); + StringBuffer value=new StringBuffer(); + CookieTools.getCookieHeaderValue(cookie,value); + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_HEADER); this.packet.writeString(name); this.packet.writeString(value.toString()); this.connection.send(this.packet); - } - } + } + } - this.packet.reset(); + this.packet.reset(); this.packet.setType(Constants.TYPE_RES_COMMIT); this.connection.send(this.packet); committed = true; } - - /** + + /** * The <code>OutputStream</code> that will handle all response body * transmission. */ @@ -266,14 +266,14 @@ this.response=response; this.packet=new WarpPacket(); } - + /** * Write one byte of data to the <code>WarpPacket</code> nested * within this <code>WarpResponse.Stream</code>. All data is buffered * until the <code>flush()</code> or <code>close()</code> method is * not called. */ - public void write(int b) + public void write(int b) throws IOException { if (closed) throw new IOException("Stream closed"); packet.buffer[packet.size++]=(byte)b; @@ -301,7 +301,7 @@ response.getConnection().send(packet); packet.reset(); } - + /** * Flush this <code>WarpResponse.Stream</code> and close it. */