felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgil...@apache.org
Subject svn commit: r1212974 - in /felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite: server/Connection.java server/ResourceHandler.java servlet/HttpServletRequestImpl.java servlet/HttpServletResponseImpl.java
Date Sun, 11 Dec 2011 07:30:04 GMT
Author: kgilmer
Date: Sun Dec 11 07:30:04 2011
New Revision: 1212974

URL: http://svn.apache.org/viewvc?rev=1212974&view=rev
Log:
httplite: append 'index.html' to GET resources paths that end in '/'.  Logging polish.  HTTP
response fix.

Modified:
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/Connection.java
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
    felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/Connection.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/Connection.java?rev=1212974&r1=1212973&r2=1212974&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/Connection.java
(original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/Connection.java
Sun Dec 11 07:30:04 2011
@@ -181,8 +181,8 @@ public class Connection
                 boolean error = false;
 
                 m_logger.log(Logger.LOG_DEBUG,
-                    "Processing request (" + (m_requestLimit - m_requestCount)
-                        + " remaining) : " + request.getRequestURI());
+                    "Processing " + request.getRequestURI() + " (" + (m_requestLimit - m_requestCount)
+                        + " remaining)");
 
                 // If client is HTTP/1.1, then send continue message.
                 if (request.getProtocol().equals(HttpConstants.HTTP11_VERSION))

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java?rev=1212974&r1=1212973&r2=1212974&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
(original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
Sun Dec 11 07:30:04 2011
@@ -39,7 +39,8 @@ import org.osgi.service.http.HttpContext
 public class ResourceHandler implements ServiceRegistrationHandler
 {
 
-    private final HttpServletRequestImpl m_request;
+    private static final String INDEX_HTML = "index.html";
+	private final HttpServletRequestImpl m_request;
     private final HttpServletResponseImpl m_response;
 
     private final HttpContext m_httpContext;
@@ -79,15 +80,25 @@ public class ResourceHandler implements 
         {
 
             //POST, PUT, DELETE operations not valid on resources.
+        	m_logger.log(Logger.LOG_WARNING, "Ignored client " + m_request.getMethod() + " on
static resource.");
             return;
         }
 
         if (m_httpContext.handleSecurity(m_request, m_response))
         {
             String resourceName = getResourceName(m_request.getRequestURI());
-
-            URL resource = m_httpContext.getResource(resourceName);
-
+            
+            URL resource = null;
+            
+            if (resourceName.endsWith("/"))
+            {
+            	m_logger.log(Logger.LOG_DEBUG, "Appending " + INDEX_HTML + " to request " +
resourceName);
+            	resource = m_httpContext.getResource(resourceName + INDEX_HTML);
+            } 
+            else 
+            {
+            	resource = m_httpContext.getResource(resourceName);	
+            }
            
             if (resource == null)
             {

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java?rev=1212974&r1=1212973&r2=1212974&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
(original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Sun Dec 11 07:30:04 2011
@@ -957,7 +957,7 @@ public class HttpServletRequestImpl impl
     {
         if (m_method != null && m_uri != null)
         {
-            return m_method + m_uri;
+            return m_method + " " + m_uri;
         }
 
         return super.toString();

Modified: felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java?rev=1212974&r1=1212973&r2=1212974&view=diff
==============================================================================
--- felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
(original)
+++ felix/sandbox/kgilmer/httplite-test-pojosr/httplite/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
Sun Dec 11 07:30:04 2011
@@ -665,8 +665,12 @@ public class HttpServletResponseImpl imp
         buffer.append(' ');
         buffer.append(code);
         buffer.append(' ');
-        buffer.append("HTTP Error ");
-        buffer.append(code);
+        
+        if (code > 399)
+        {
+	        buffer.append("HTTP Error ");
+	        buffer.append(code);
+        }
         buffer.append(HttpConstants.HEADER_DELEMITER);
         if (code == 100)
         {
@@ -698,6 +702,7 @@ public class HttpServletResponseImpl imp
         //Only append error HTML messages if the return code is in the error range.
         if (code > 399)
         {
+        	//TODO: Consider disabling the HTML generation, optionally, so clients have full
control of the response content.
             if (htmlStartTag == null)
             {
                 htmlStartTag = HttpConstants.DEFAULT_HTML_HEADER;



Mime
View raw message