svn commit: r833521 [2/2] - in /tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat: integration/simple/ lite/ lite/coyote/

View: New views
1 Messages — Rating Filter:   Alert me  

svn commit: r833521 [2/2] - in /tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat: integration/simple/ lite/ lite/coyote/

by Tim Funk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletRequestImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletRequestImpl.java?rev=833521&r1=833520&r2=833521&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletRequestImpl.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletRequestImpl.java Fri Nov  6 18:53:57 2009
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999,2004 The Apache Software Foundation.
- *
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@
 import java.security.Principal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -68,7 +69,7 @@
 
 
 /**
- *
+ *
  * Wrapper object for the Coyote request.
  *
  * @author Remy Maucherat
@@ -95,13 +96,13 @@
     /**
      * Request dispatcher state.
      */
-    public static final String DISPATCHER_TYPE_ATTR =
+    public static final String DISPATCHER_TYPE_ATTR =
         "org.apache.catalina.core.DISPATCHER_TYPE";
 
     /**
      * Request dispatcher path.
      */
-    public static final String DISPATCHER_REQUEST_PATH_ATTR =
+    public static final String DISPATCHER_REQUEST_PATH_ATTR =
         "org.apache.catalina.core.DISPATCHER_REQUEST_PATH";
 
     /**
@@ -175,7 +176,7 @@
     public static final String SERVLET_NAME_ATTR =
         "javax.servlet.error.servlet_name";
 
-    
+
     /**
      * The name of the cookie used to pass the session identifier back
      * and forth with the client.
@@ -204,7 +205,7 @@
     public static final String SUBJECT_ATTR =
         "javax.security.auth.subject";
 
-    
+
     /**
      * The servlet context attribute under which we store a temporary
      * working directory (as an object of type File) for use by servlets
@@ -228,7 +229,7 @@
      * The match string for identifying a session ID parameter.
      */
     private static final String match = ";" + SESSION_PARAMETER_NAME + "=";
-  
+
     /**
      * The set of cookies associated with this Request.
      */
@@ -242,7 +243,7 @@
      * declare formats[] as a static variable.
      */
     protected SimpleDateFormat formats[] = null;
-    
+
 
     /**
      * The attributes associated with this Request, keyed by attribute name.
@@ -295,14 +296,14 @@
     /**
      * ServletInputStream.
      */
-    protected ServletInputStreamImpl inputStream;
+    protected ServletInputStreamImpl inputStream;
 
 
     /**
      * Reader.
      */
     protected BufferedReader reader;
-    
+
 
     /**
      * Using stream flag.
@@ -395,7 +396,7 @@
      * Filter chain associated with the request.
      */
     protected FilterChainImpl filterChain = new FilterChainImpl();
-    
+
     /**
      * Mapping data.
      */
@@ -408,7 +409,7 @@
      * The response with which this request is associated.
      */
     protected ServletResponseImpl response = new ServletResponseImpl();
-    
+
     /**
      * URI byte to char converter (not recycled).
      */
@@ -423,13 +424,13 @@
      * Post data buffer.
      */
     public final static int CACHED_POST_LEN = 8192;
-    
+
     public  byte[] postData = null;
 
-    
+
     private HttpRequest httpRequest;
-    
-    /** New IO/buffer model  
+
+    /** New IO/buffer model
      */
     //protected Http11Connection con;
 
@@ -499,7 +500,7 @@
     public void setConnector(Connector c) {
         connector = c;
     }
-    
+
     public Connector getConnector() {
         return connector;
     }
@@ -563,7 +564,7 @@
      *
      * @exception IOException if an input/output error occurs
      */
-    public ServletInputStream createInputStream()
+    public ServletInputStream createInputStream()
         throws IOException {
         return inputStream;
     }
@@ -588,11 +589,11 @@
     public Object getAttribute(String name) {
 
         if (name.equals(ServletRequestImpl.DISPATCHER_TYPE_ATTR)) {
-            return (dispatcherType == null)
+            return (dispatcherType == null)
                 ? REQUEST_INTEGER
                 : dispatcherType;
         } else if (name.equals(ServletRequestImpl.DISPATCHER_REQUEST_PATH_ATTR)) {
-            return (requestDispatcherPath == null)
+            return (requestDispatcherPath == null)
                 ? getRequestPathMB().toString()
                 : requestDispatcherPath.toString();
         }
@@ -606,7 +607,7 @@
 //        if(attr != null)
 //            return attr;
 //        if( isSSLAttribute(name) ) {
-//            reqB.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
+//            reqB.action(ActionCode.ACTION_REQ_SSL_ATTRIBUTE,
 //                                 reqB);
 //            attr = reqB.getAttribute(ServletRequestImpl.CERTIFICATES_ATTR);
 //            if( attr != null) {
@@ -738,7 +739,7 @@
 
     /**
      * Get the context path.
-     *
+     *
      * @return the context path
      */
     public MessageBytes getContextPathMB() {
@@ -783,7 +784,7 @@
             formats[1].setTimeZone(GMT_ZONE);
             formats[2].setTimeZone(GMT_ZONE);
         }
-        
+
         // Attempt to convert the date header in a variety of formats
         long result = FastHttpDateFormat.parseDate(value, formats);
         if (result != (-1L)) {
@@ -796,7 +797,7 @@
 
     /**
      * Get the decoded request URI.
-     *
+     *
      * @return the URL decoded request URI
      */
     public String getDecodedRequestURI() {
@@ -806,7 +807,7 @@
 
     /**
      * Get the decoded request URI.
-     *
+     *
      * @return the URL decoded request URI
      */
     public MessageBytes getDecodedRequestURIMB() {
@@ -833,7 +834,7 @@
     public String getHeader(String name) {
         return httpRequest.getHeader(name);
     }
-    
+
     /**
      * Return the names of all headers received with this request.
      */
@@ -897,7 +898,7 @@
     /**
      * Returns the Internet Protocol (IP) address of the interface on
      * which the request  was received.
-     */      
+     */
     public String getLocalAddr(){
         return httpRequest.localAddr().toString();
     }
@@ -1062,7 +1063,7 @@
 
     /**
      * Get the path info.
-     *
+     *
      * @return the path info
      */
     public MessageBytes getPathInfoMB() {
@@ -1086,14 +1087,14 @@
         }
 
     }
-    
+
     /**
      * Return the principal that has been authenticated for this Request.
      */
     public Principal getPrincipal() {
         return (userPrincipal);
     }
-    
+
     /**
      * Return the protocol and version used to make this Request.
      */
@@ -1145,7 +1146,7 @@
     /**
      *  Converter for the encoding associated with the request.
      *  If encoding is changed - a different encoder will be returned.
-     *  
+     *
      *  Encoders are cached ( per request ) - at least 8K per charset
      */
     public B2CConverter getB2C() throws IOException {
@@ -1153,7 +1154,7 @@
       if (enc == null) {
         enc = DEFAULT_CHARACTER_ENCODING;
       }
-      B2CConverter conv =
+      B2CConverter conv =
         (B2CConverter) encoders.get(enc);
       if (conv == null) {
         conv = new B2CConverter(enc);
@@ -1161,7 +1162,7 @@
       }
       return conv;
     }
-    
+
     /**
      * Return the real path of the specified virtual path.
      *
@@ -1213,7 +1214,7 @@
     /**
      * Returns the Internet Protocol (IP) source port of the client
      * or last proxy that sent the request.
-     */    
+     */
     public int getRemotePort(){
         return httpRequest.getRemotePort();
     }
@@ -1241,11 +1242,11 @@
     public HttpServletRequest getRequest() {
         return this;
     }
-    
+
     public HttpRequest getHttpRequest() {
       return httpRequest;
     }
-    
+
     public void setHttpRequest(HttpRequest req, BodyReader in) {
       this.httpRequest = req;
       inputBuffer = in;
@@ -1316,7 +1317,7 @@
 
     /**
      * Get the request path.
-     *
+     *
      * @return the request path
      */
     public MessageBytes getRequestPathMB() {
@@ -1330,13 +1331,13 @@
     public String getRequestURI() {
         return httpRequest.requestURI().toString();
     }
-    
+
     /**
      */
     public void setRequestURI(String uri) {
       httpRequest.decodedURI().setString(uri);
       try {
-        UriNormalizer.decodeRequest(httpRequest.decodedURI(),
+        UriNormalizer.decodeRequest(httpRequest.decodedURI(),
                 httpRequest.requestURI(), httpRequest.getURLDecoder());
       } catch(IOException ioe) {
         ioe.printStackTrace();
@@ -1432,7 +1433,7 @@
 
     /**
      * Get the servlet path.
-     *
+     *
      * @return the servlet path
      */
     public MessageBytes getServletPathMB() {
@@ -1537,8 +1538,8 @@
     public boolean isSecure() {
         return (secure);
     }
-    
-    
+
+
     /**
      * Return <code>true</code> if the authenticated user principal
      * possesses the specified role name.
@@ -1566,7 +1567,7 @@
         if (role.equals(userPrincipal.getName())) {
             return true;
         }
-        
+
         // TODO: check !!!!
         // Check for a role defined directly as a <security-role>
         return false;
@@ -1652,7 +1653,7 @@
                 (ServletRequestAttributeListener) listeners.get(i);
             try {
                 if (event == null) {
-                    event =
+                    event =
                         new ServletRequestAttributeEvent(context.getServletContext(),
                             getRequest(), name, value);
                 }
@@ -1673,7 +1674,7 @@
      * @param value The associated value
      */
     public void setAttribute(String name, Object value) {
-
+
         // Name cannot be null
         if (name == null)
             throw new IllegalArgumentException
@@ -1712,7 +1713,7 @@
 //        if (name.startsWith("org.apache.tomcat.")) {
 //            reqB.setAttribute(name, value);
 //        }
-//        
+//
         // Notify interested application event listeners
         List listeners = context.getListeners();
         if (listeners.size() == 0)
@@ -1862,7 +1863,7 @@
 
     /**
      * Set the decoded request URI.
-     *
+     *
      * @param uri The decoded request URI
      */
     public void setDecodedRequestURI(String uri) {
@@ -2051,18 +2052,18 @@
 
         if (System.getSecurityManager() != null){
             HttpSession session = getSession(false);
-            if ( (subject != null) &&
+            if ( (subject != null) &&
                  (!subject.getPrincipals().contains(principal)) ){
-                subject.getPrincipals().add(principal);        
+                subject.getPrincipals().add(principal);
             } else if (session != null &&
                         session.getAttribute(ServletRequestImpl.SUBJECT_ATTR) == null) {
                 subject = new Subject();
-                subject.getPrincipals().add(principal);        
+                subject.getPrincipals().add(principal);
             }
             if (session != null){
                 session.setAttribute(ServletRequestImpl.SUBJECT_ATTR, subject);
             }
-        }
+        }
 
         this.userPrincipal = principal;
     }
@@ -2092,7 +2093,7 @@
     protected void configureSessionCookie(Cookie cookie) {
         cookie.setMaxAge(-1);
         String contextPath = null;
-        if (//!connector.getEmptySessionPath() &&
+        if (//!connector.getEmptySessionPath() &&
                 (getContext() != null)) {
             contextPath = getContext().getEncodedPath();
         }
@@ -2129,14 +2130,14 @@
             manager = context.getManager();
         if (manager == null)
             return (null);      // Sessions are not supported
-        
+
         // Return the current session if it exists and is valid
         if ((session != null) && !manager.isValid(session))
             session = null;
         if (session != null)
             return (session);
-        
-        
+
+
         if (requestedSessionId != null) {
             try {
                 session = manager.findSession(requestedSessionId);
@@ -2360,7 +2361,7 @@
      */
     protected void parseSessionCookiesId() {
         String sessionCookieName = context.getSessionCookieName();
-        
+
         // Parse session id from cookies
         Cookies serverCookies = httpRequest.getCookies();
         int count = serverCookies.getCookieCount();
@@ -2374,7 +2375,7 @@
                 if (!isRequestedSessionIdFromCookie()) {
                     // Accept only the first session id cookie
                     //scookie.getValue().convertToAscii();
-                    
+
                     setRequestedSessionId
                         (scookie.getValue().toString());
                     setRequestedSessionCookie(true);
@@ -2409,18 +2410,18 @@
             int semicolon2 = uriBC.indexOf(';', sessionIdStart);
             if (semicolon2 >= 0) {
                 request.setRequestedSessionId
-                    (new String(uriBC.getBuffer(), start + sessionIdStart,
+                    (new String(uriBC.getBuffer(), start + sessionIdStart,
                             semicolon2 - sessionIdStart));
                 // Extract session ID from request URI
                 byte[] buf = uriBC.getBuffer();
                 for (int i = 0; i < end - start - semicolon2; i++) {
-                    buf[start + semicolon + i]
+                    buf[start + semicolon + i]
                         = buf[start + i + semicolon2];
                 }
                 uriBC.setBytes(buf, start, end - start - semicolon2 + semicolon);
             } else {
                 request.setRequestedSessionId
-                    (new String(uriBC.getBuffer(), start + sessionIdStart,
+                    (new String(uriBC.getBuffer(), start + sessionIdStart,
                             (end - start) - sessionIdStart));
                 uriBC.setEnd(start + semicolon);
             }
@@ -2464,54 +2465,57 @@
     }
 
 
-    @Override
     public void addAsyncListener(AsyncListener listener) {
     }
 
 
-    @Override
+
     public void addAsyncListener(AsyncListener listener,
                                  ServletRequest servletRequest,
                                  ServletResponse servletResponse) {
     }
 
 
+
     @Override
     public AsyncContext getAsyncContext() {
         return null;
     }
 
 
+
     @Override
     public ServletContext getServletContext() {
         return null;
     }
 
 
+
     @Override
     public boolean isAsyncStarted() {
         return false;
     }
 
 
+
     @Override
     public boolean isAsyncSupported() {
         return false;
     }
 
 
-    @Override
     public void setAsyncTimeout(long timeout) {
     }
 
 
-    @Override
+
+   @Override
     public AsyncContext startAsync() throws IllegalStateException {
         return null;
     }
 
 
-    @Override
+   @Override
     public AsyncContext startAsync(ServletRequest servletRequest,
                                    ServletResponse servletResponse)
             throws IllegalStateException {
@@ -2519,45 +2523,50 @@
     }
 
 
-    @Override
+
+   @Override
     public boolean authenticate(HttpServletResponse response)
             throws IOException, ServletException {
         return false;
     }
 
 
-    @Override
+
+   @Override
     public Part getPart(String name) {
         return null;
     }
 
 
-    @Override
-    public Iterable<Part> getParts() {
-        return null;
-    }
-
 
-    @Override
+   @Override
     public void login(String username, String password) throws ServletException {
     }
 
 
-    @Override
+
+   @Override
     public void logout() throws ServletException {
     }
 
 
-    @Override
+
     public long getAsyncTimeout() {
         return 0;
     }
 
 
-    @Override
+
+   @Override
     public DispatcherType getDispatcherType() {
         return null;
     }
 
 
+   @Override
+    public Collection<Part> getParts() throws IOException, ServletException {
+        return null;
+    }
+
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletResponseImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletResponseImpl.java?rev=833521&r1=833520&r2=833521&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletResponseImpl.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/ServletResponseImpl.java Fri Nov  6 18:53:57 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,6 +24,7 @@
 import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -53,7 +54,7 @@
 public class ServletResponseImpl
     implements HttpServletResponse {
 
-    /**
+    /**
      * Format for http response header date field
      * From DateTool
      */
@@ -61,8 +62,8 @@
         "EEE, dd MMM yyyy HH:mm:ss zzz";
 
     // ----------------------------------------------------------- Constructors
-    
-    
+
+
     ServletResponseImpl() {
         urlEncoder.addSafeCharacter('/');
     }
@@ -103,12 +104,12 @@
      */
     protected boolean included = false;
 
-    
+
     /**
      * The characterEncoding flag
      */
     private boolean isCharacterEncodingSet = false;
-    
+
     /**
      * The error flag.
      */
@@ -151,19 +152,19 @@
 
 
     private HttpResponse resB;
-    
-    
+
+
     // Cached/derived information - reflected in headers
     protected static Locale DEFAULT_LOCALE = Locale.getDefault();
-    
+
     public static final String DEFAULT_CHARACTER_ENCODING="ISO-8859-1";
 
     protected Locale locale = DEFAULT_LOCALE;
 
-    // XXX
+    // XXX
     protected boolean commited = false;
     protected String contentType = null;
-    
+
     /**
      * Has the charset been explicitly set.
      */
@@ -187,11 +188,11 @@
         included = false;
         error = false;
         isCharacterEncodingSet = false;
-        
+
         cookies.clear();
 
         outputBuffer.recycle();
-        
+
         resB.recycle();
     }
 
@@ -209,7 +210,7 @@
 
     /**
      * Set the application commit flag.
-     *
+     *
      * @param appCommitted The new application committed flag value
      */
     public void setAppCommitted(boolean appCommitted) {
@@ -222,7 +223,7 @@
      */
     public boolean isAppCommitted() {
         return (this.appCommitted || isCommitted() || isSuspended()
-                || ((getHttpResponse().getContentLength() > 0)
+                || ((getHttpResponse().getContentLength() > 0)
                     && (getContentCount() >= getHttpResponse().getContentLength())));
     }
 
@@ -283,7 +284,7 @@
 
     /**
      * Set the suspended flag.
-     *
+     *
      * @param suspended The new suspended flag value
      */
     public void setSuspended(boolean suspended) throws IOException {
@@ -323,7 +324,7 @@
      *
      * @exception IOException if an input/output error occurs
      */
-    public ServletOutputStream createOutputStream()
+    public ServletOutputStream createOutputStream()
         throws IOException {
         // Probably useless
         return outputStream;
@@ -336,7 +337,7 @@
     public String getContentType() {
         String ret = contentType;
 
-        if (ret != null
+        if (ret != null
             && characterEncoding != null
             && charsetSet) {
             ret = ret + ";charset=" + characterEncoding;
@@ -379,7 +380,7 @@
      *
      * @exception IOException if an input/output error occurs
      */
-    public void flushBuffer()
+    public void flushBuffer()
         throws IOException {
         outputBuffer.flush();
     }
@@ -408,7 +409,7 @@
      *  already been called for this response
      * @exception IOException if an input/output error occurs
      */
-    public ServletOutputStream getOutputStream()
+    public ServletOutputStream getOutputStream()
         throws IOException {
 
         if (usingWriter)
@@ -439,7 +440,7 @@
      *  already been called for this response
      * @exception IOException if an input/output error occurs
      */
-    public PrintWriter getWriter()
+    public PrintWriter getWriter()
         throws IOException {
 
         if (usingOutputStream)
@@ -490,14 +491,14 @@
 
         if (isCommitted())
             throw new IllegalStateException("isCommitted");
-        
+
         resB.recycle(); // reset headers, status code, message
         req.getConnector().reset(this);
         contentType = null;
         locale = DEFAULT_LOCALE;
         characterEncoding = DEFAULT_CHARACTER_ENCODING;
         charsetSet = false;
-        
+
         outputBuffer.reset();
     }
 
@@ -539,7 +540,7 @@
 
     /**
      * Set the content length (in bytes) for this Response.
-     * Ignored for writers if non-ISO-8859-1 encoding ( we could add more
+     * Ignored for writers if non-ISO-8859-1 encoding ( we could add more
      * encodings that are constant.
      */
     public void setContentLength(int length) {
@@ -550,8 +551,8 @@
         // Ignore any call from an included servlet
         if (included)
             return;
-        
-        // writers can use variable-length encoding.
+
+        // writers can use variable-length encoding.
         if (usingWriter && !"ISO-8859-1".equals(getCharacterEncoding())) {
             return;
         }
@@ -622,11 +623,11 @@
 
         if (isCommitted())
             return;
-        
+
         // Ignore any call from an included servlet
         if (included)
-            return;    
-        
+            return;
+
         // Ignore any call made after the getWriter has been invoked
         // The default should be used
         if (usingWriter)
@@ -642,8 +643,8 @@
         isCharacterEncodingSet = true;
     }
 
-    
-    
+
+
     /**
      * Set the Locale that is appropriate for this response, including
      * setting the appropriate character encoding.
@@ -670,7 +671,7 @@
         String contentLanguage = locale.getLanguage();
         if ((contentLanguage != null) && (contentLanguage.length() > 0)) {
             String country = locale.getCountry();
-            StringBuilder value = new StringBuilder(contentLanguage);
+            StringBuffer value = new StringBuffer(contentLanguage);
             if ((country != null) && (country.length() > 0)) {
                 value.append('-');
                 value.append(country);
@@ -726,7 +727,7 @@
      * Return an array of all the header names set for this response, or
      * a zero-length array if no headers have been set.
      */
-    public Iterable<String> getHeaderNames() {
+    public Collection<String> getHeaderNames() {
 
         MimeHeaders headers = getHttpResponse().getMimeHeaders();
         int n = headers.size();
@@ -809,10 +810,10 @@
 
         cookies.add(cookie);
 
-        final StringBuilder sb = new StringBuilder();
+        final StringBuffer sb = new StringBuffer();
         ServerCookie.appendCookieValue
         (sb, cookie.getVersion(), cookie.getName(), cookie.getValue(),
-                cookie.getPath(), cookie.getDomain(), cookie.getComment(),
+                cookie.getPath(), cookie.getDomain(), cookie.getComment(),
                 cookie.getMaxAge(), cookie.getSecure(), false);
 
         // the header name is Set-Cookie for both "old" and v.1 ( RFC2109 )
@@ -952,10 +953,10 @@
      * @param url URL to be encoded
      */
     public String encodeURL(String url) {
-        
+
         String absolute = toAbsolute(url);
         if (isEncodeable(absolute)) {
-            // W3c spec clearly said
+            // W3c spec clearly said
             if (url.equalsIgnoreCase("")){
                 url = absolute;
             }
@@ -983,7 +984,7 @@
 
     /**
      * Send an acknowledgment of a request.
-     *
+     *
      * @exception IOException if an input/output error occurs
      */
     public void sendAcknowledgement()
@@ -994,7 +995,7 @@
 
         // Ignore any call from an included servlet
         if (included)
-            return;
+            return;
 
         req.getConnector().acknowledge(this);
     }
@@ -1010,7 +1011,7 @@
      *  already been committed
      * @exception IOException if an input/output error occurs
      */
-    public void sendError(int status)
+    public void sendError(int status)
         throws IOException {
         sendError(status, null);
     }
@@ -1026,7 +1027,7 @@
      *  already been committed
      * @exception IOException if an input/output error occurs
      */
-    public void sendError(int status, String message)
+    public void sendError(int status, String message)
         throws IOException {
 
         if (isCommitted())
@@ -1035,7 +1036,7 @@
 
         // Ignore any call from an included servlet
         if (included)
-            return;
+            return;
 
         setError();
 
@@ -1055,10 +1056,10 @@
             // TODO: maybe other mechanism to customize default.
             defaultStatusPage(status, message);
         }
-        setSuspended(true);        
+        setSuspended(true);
     }
 
-    /**
+    /**
      * Default handler for status code != 200
      */
     void defaultStatusPage(int status, String message)
@@ -1066,15 +1067,15 @@
         setContentType("text/html");
         if (status > 400 && status < 600) {
             if (getOutputBuffer().getBytesWritten() == 0) {
-                getOutputBuffer().write("<html><body><h1>Status: " +
-                        status + "</h1><h1>Message: " + message +
+                getOutputBuffer().write("<html><body><h1>Status: " +
+                        status + "</h1><h1>Message: " + message +
                         "</h1></body></html>");
                 getOutputBuffer().flush();
             }
         }
     }
 
-    
+
 
     /**
      * Send a temporary redirect to the specified redirect location URL.
@@ -1085,7 +1086,7 @@
      *  already been committed
      * @exception IOException if an input/output error occurs
      */
-    public void sendRedirect(String location)
+    public void sendRedirect(String location)
         throws IOException {
 
         if (isCommitted())
@@ -1094,7 +1095,7 @@
 
         // Ignore any call from an included servlet
         if (included)
-            return;
+            return;
 
         // Clear any data content that has been buffered
         resetBuffer();
@@ -1248,7 +1249,7 @@
             return (false);
         if (hreq.isRequestedSessionIdFromCookie())
             return (false);
-        
+
         // Is this a valid absolute URL?
         URL url = null;
         try {
@@ -1333,7 +1334,7 @@
                     String relativePath = req.getDecodedRequestURI();
                     int pos = relativePath.lastIndexOf('/');
                     relativePath = relativePath.substring(0, pos);
-                    
+
                     String encodedURI = null;
                     encodedURI = urlEncoder.encodeURL(relativePath);
                     redirectURLCC.append(encodedURI, 0, encodedURI.length());
@@ -1383,7 +1384,7 @@
             c == '+' || c == '-' || c == '.';
     }
 
-    
+
     /**
      * Return the specified URL with the specified session identifier
      * suitably encoded.
@@ -1409,7 +1410,7 @@
             anchor = path.substring(pound);
             path = path.substring(0, pound);
         }
-        StringBuilder sb = new StringBuilder(path);
+        StringBuffer sb = new StringBuffer(path);
         if( sb.length() > 0 ) { // jsessionid can't be first.
             sb.append(";jsessionid=");
             sb.append(sessionId);
@@ -1428,7 +1429,7 @@
     public BodyWriter getOutputBuffer() {
       return outputBuffer;
     }
-    
+
     public void setWriter(BodyWriter ob) {
         outputBuffer = ob;
         outputStream = new ServletOutputStreamImpl(outputBuffer);
@@ -1451,8 +1452,9 @@
     }
 
 
-    @Override
-    public Iterable<String> getHeaders(String name) {
+
+   @Override
+    public Collection<String> getHeaders(String name) {
         return null;
     }
 

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/coyote/CoyoteConnector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/coyote/CoyoteConnector.java?rev=833521&r1=833520&r2=833521&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/coyote/CoyoteConnector.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/coyote/CoyoteConnector.java Fri Nov  6 18:53:57 2009
@@ -39,18 +39,18 @@
 
     public void acknowledge(HttpServletResponse res) throws IOException {
         Response cres = (Response) ((ServletResponseImpl) res).getHttpResponse().nativeResponse;
-        cres.acknowledge();        
+        cres.acknowledge();
     }
 
     public void reset(HttpServletResponse res) {
         Response cres = (Response) ((ServletResponseImpl) res).getHttpResponse().nativeResponse;
-        cres.reset();        
+        cres.reset();
     }
-    
+
     public void recycle(HttpServletRequest req, HttpServletResponse res) {
-    
+
     }
-    
+
     public static HttpResponse getResponse(final Response cres) {
         HttpResponse hres = new HttpResponse() {
             public int getStatus() {
@@ -75,101 +75,101 @@
                 cres.setCommitted(b);
             }
         };
-        
+
         hres.setMimeHeaders(cres.getMimeHeaders());
         hres.nativeResponse = cres;
-        
+
         return hres;
     }
-    
+
     public static HttpRequest getRequest(Request req) {
-        
+
         HttpRequest httpReq = new HttpRequest(req.scheme(),
-                req.method(),
+                req.method(),
                 req.unparsedURI(),
                 req.protocol(),
                 req.getMimeHeaders(),
                 req.requestURI(),
                 req.decodedURI(),
                 req.query(), req.getParameters(),
-                req.serverName(),
+                req.serverName(),
                 req.getCookies()) {
-            
+
         };
         httpReq.nativeRequest = req;
-        
+
         // TODO: anything else computed in coyote ?
-        
+
         return httpReq;
     }
 
     @Override
     public void initRequest(HttpServletRequest hreq, HttpServletResponse hres) {
         ServletRequestImpl req = (ServletRequestImpl) hreq;
-        ServletResponseImpl res = (ServletResponseImpl) hres;        
+        ServletResponseImpl res = (ServletResponseImpl) hres;
         req.setConnector(this);
-        
+
         Request creq = new Request();
         Response cres = new Response();
         HttpResponse nRes = getResponse(cres);
 
         BodyWriter out = new BodyWriter(4096);
         out.setConnector(this, res);
-        
+
         res.setHttpResponse(nRes, out);
-        
+
         cres.setRequest(creq);
         cres.setHook(new ActionHook() {
-          public void action(ActionCode actionCode,
+          public void action(ActionCode actionCode,
                              Object param) {
           }
         });
-        
+
         BodyReader in = new BodyReader();
         in.setConnector(this, req);
         HttpRequest nReq = getRequest(creq);
         req.setHttpRequest(nReq, in);
-        
+
     }
-      
+
 
     // ---- Coyote Adapter interface ---
-    
+
     @Override
     public void service(Request creq, Response cres) throws Exception {
         long t0 = System.currentTimeMillis();
 
         // compute decodedURI - not done by connector
         UriNormalizer.decodeRequest(creq.decodedURI(), creq.requestURI(), creq.getURLDecoder());
-        
+
         // find the facades
         ServletRequestImpl req = (ServletRequestImpl) creq.getNote(ADAPTER_REQ_NOTE);
         ServletResponseImpl res = (ServletResponseImpl) cres.getNote(ADAPTER_RES_NOTE);
 
-        
+
         if (req == null) {
           req = new ServletRequestImpl();
           res = req.getResponse();
-          
+
           BodyReader in = new BodyReader();
           in.setConnector(this, req);
 
           HttpRequest nReq = getRequest(creq);
           nReq.setServerPort(creq.getServerPort());
           HttpResponse nRes = getResponse(cres);
-          
+
           req.setHttpRequest(nReq, in);
           BodyWriter out = new BodyWriter(4096);
           out.setConnector(this, res);
-          
+
           res.setHttpResponse(nRes, out);
-          
+
           creq.setNote(ADAPTER_REQ_NOTE, req);
           cres.setNote(ADAPTER_RES_NOTE, res);
-          
+
         }
         req.setConnector(this);
-        
+
         try {
             lite.service(req, res);
         } catch(IOException ex) {
@@ -178,14 +178,14 @@
             t.printStackTrace();
         } finally {
             long t1 = System.currentTimeMillis();
-            
-//            log.info("<<<<<<<< DONE: " + creq.method() + " " +
-//                    creq.decodedURI() + " " +
-//                    res.getStatus() + " " +
+
+//            log.info("<<<<<<<< DONE: " + creq.method() + " " +
+//                    creq.decodedURI() + " " +
+//                    res.getStatus() + " " +
 //                    (t1 - t0));
-            
+
             // Final processing
-            // TODO: only if not commet, this doesn't work with the
+            // TODO: only if not commet, this doesn't work with the
             // other connectors since we don't have the info
             // TODO: add this note in the nio/apr connectors
             // TODO: play nice with TomcatLite, other adapters that flush/close
@@ -195,7 +195,7 @@
                     cres.sendHeaders();
                 }
                 res.getOutputBuffer().flush();
-                
+
                 BodyWriter mw = res.getBodyWriter();
                 //MessageWriter.getWriter(creq, cres, 0);
                 mw.flush();
@@ -204,7 +204,7 @@
                 BodyReader reader = req.getBodyReader();
                 //getReader(creq);
                 reader.recycle();
-                
+
                 cres.finish();
 
                 creq.recycle();
@@ -215,7 +215,7 @@
             }
         }
     }
-        
+
     @Override
     public boolean event(Request req, Response res, SocketStatus status)
         throws Exception {
@@ -230,7 +230,7 @@
 
     public String getRemoteHost(HttpServletRequest hreq) {
         ServletRequestImpl req = (ServletRequestImpl) hreq;
-        
+
         Request creq = (Request) req.getHttpRequest().nativeRequest;
         creq.action(ActionCode.ACTION_REQ_HOST_ATTRIBUTE, creq);
         return creq.remoteHost().toString();
@@ -238,7 +238,7 @@
 
     public String getRemoteAddr(HttpServletRequest hreq) {
         ServletRequestImpl req = (ServletRequestImpl) hreq;
-        
+
         Request creq = (Request) req.getHttpRequest().nativeRequest;
         creq.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, creq);
         return creq.remoteAddr().toString();
@@ -248,8 +248,8 @@
     @Override
     public void beforeClose(HttpServletResponse res, int len) throws IOException {
         Response cres = (Response) ((ServletResponseImpl) res).getHttpResponse().nativeResponse;
-    
-        if ((!cres.isCommitted())
+
+        if ((!cres.isCommitted())
                 && (cres.getContentLengthLong() == -1)) {
                 // Flushing the char buffer
                 // If this didn't cause a commit of the response, the final content
@@ -262,7 +262,7 @@
 
     public int doRead(ServletRequestImpl hreq, ByteChunk bb) throws IOException {
         ServletRequestImpl req = (ServletRequestImpl) hreq;
-        
+
         Request creq = (Request) req.getHttpRequest().nativeRequest;
         return creq.doRead(bb);
     }
@@ -279,7 +279,7 @@
     @Override
     public void realFlush(HttpServletResponse res) throws IOException {
         Response cres = (Response) ((ServletResponseImpl) res).getHttpResponse().nativeResponse;
-        cres.action(ActionCode.ACTION_CLIENT_FLUSH,
+        cres.action(ActionCode.ACTION_CLIENT_FLUSH,
                 cres);
         // If some exception occurred earlier, or if some IOE occurred
         // here, notify the servlet with an IOE
@@ -294,7 +294,7 @@
     @Override
     public void sendHeaders(HttpServletResponse res) throws IOException {
         Response cres = (Response) ((ServletResponseImpl) res).getHttpResponse().nativeResponse;
-        
+
         // This should happen before 'prepareResponse' is called !!
         // Now update coyote response based on response
         // don't set charset/locale - they're computed in lite
@@ -312,43 +312,43 @@
     protected boolean daemon = false;
 
     /**
-     * Note indicating the response is COMET.
+     * Note indicating the response is COMET.
      */
     public static final int COMET_RES_NOTE = 2;
     public static final int COMET_REQ_NOTE = 2;
-    
-    public static final int ADAPTER_RES_NOTE = 1;    
-    public static final int ADAPTER_REQ_NOTE = 1;    
-    
+
+    public static final int ADAPTER_RES_NOTE = 1;
+    public static final int ADAPTER_REQ_NOTE = 1;
+
     protected ProtocolHandler proto;
 
     //protected Adapter adapter = new MapperAdapter();
     protected int maxThreads = 20;
     boolean started = false;
     boolean async = false; // use old nio connector
-    
+
     protected ObjectManager om;
-    
-    
+
+
     public void setObjectManager(ObjectManager om) {
         this.om = om;
     }
-    
-    /**
+
+    /**
      * Add an adapter. If more than the 'default' adapter is
      * added, a MapperAdapter will be inserted.
-     *
+     *
      * @param path Use "/" for the default.
      * @param adapter
      */
 //    public void addAdapter(String path, Adapter added) {
 //        if ("/".equals(path)) {
-//            ((MapperAdapter) adapter).setDefaultAdapter(added);        
+//            ((MapperAdapter) adapter).setDefaultAdapter(added);
 //        } else {
 //            ((MapperAdapter) adapter).getMapper().addWrapper(path, added);
 //        }
 //    }
-    
+
     /**
      */
     public void run() {
@@ -363,7 +363,7 @@
     public void setDaemon(boolean b) {
       daemon = b;
     }
-    
+
     protected void initAdapters() {
         if (proto == null) {
             addProtocolHandler(port, daemon);
@@ -380,7 +380,7 @@
       proto.destroy();
       started = false;
     }
-    
+
 //    /**
 //     *  Simple CLI support - arg is a path:className pair.
 //     */
@@ -394,14 +394,14 @@
 //        e.printStackTrace();
 //      }
 //    }
-    
+
     public void setConnector(ProtocolHandler h) {
         this.proto = h;
         h.setAttribute("port", Integer.toString(port));
 
         om.bind("ProtocolHandler:" + "ep-" + port, proto);
     }
-    
+
     public void addProtocolHandler(int port, boolean daemon) {
         Http11NioProtocol proto = new Http11NioProtocol();
         proto.setCompression("on");
@@ -412,29 +412,29 @@
         setPort(port);
         setDaemon(daemon);
     }
-    
-    public void addProtocolHandler(ProtocolHandler proto,
+
+    public void addProtocolHandler(ProtocolHandler proto,
                                    int port, boolean daemon) {
         setConnector(proto);
         setPort(port);
         setDaemon(daemon);
     }
-    
+
     public void setPort(int port) {
         if (proto != null) {
             proto.setAttribute("port", Integer.toString(port));
         }
         this.port = port;
       }
-      
-    
+
+
     public void init() {
         //JdkLoggerConfig.loadCustom();
-        om.bind("CoyoteConnector:" + "CoyoteConnector-" + port,
+        om.bind("CoyoteConnector:" + "CoyoteConnector-" + port,
                 this);
     }
 
-    
+
     public void start() throws IOException {
       try {
         if (started) {
@@ -446,20 +446,25 @@
         // not required - should run fine without a connector.
         if (proto != null) {
             proto.setAdapter(this);
-        
+
             proto.init();
             proto.start();
         }
-        
+
         started = true;
       } catch (Throwable e) {
         e.printStackTrace();
         throw new RuntimeException(e);
       }
     }
-    
+
     public boolean getStarted() {
       return started;
-    }
-    
+    }
+
+    public boolean asyncDispatch(Request req,Response res, SocketStatus status) throws Exception {
+        // implement me
+        return false;
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...