incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r612813 - /incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
Date Thu, 17 Jan 2008 13:31:43 GMT
Author: bdelacretaz
Date: Thu Jan 17 05:30:43 2008
New Revision: 612813

URL: http://svn.apache.org/viewvc?rev=612813&view=rev
Log:
Simple implementation of getResponseContentType()

Modified:
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java?rev=612813&r1=612812&r2=612813&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
Thu Jan 17 05:30:43 2008
@@ -21,6 +21,7 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
@@ -54,6 +55,7 @@
         SlingHttpServletRequest {
 
     private final RequestData requestData;
+    private String responseContentType;
 
     public SlingHttpServletRequestImpl(RequestData requestData,
             HttpServletRequest servletRequest) {
@@ -201,8 +203,12 @@
      * @see org.apache.sling.api.SlingHttpServletRequest#getResponseContentType()
      */
     public String getResponseContentType() {
-        // TODO Auto-generated method stub
-        return null;
+        if(responseContentType == null) {
+            final String ext = getRequestPathInfo().getExtension();
+            // TODO use Sling mime-type service??
+            responseContentType = requestData.getSlingMainServlet().getServletContext().getMimeType("dummy."
+ ext);
+        }
+        return responseContentType;
     }
 
     /**
@@ -210,8 +216,15 @@
      */
     @SuppressWarnings("unchecked")
     public Enumeration<String> getResponseContentTypes() {
-        List<String> empty = Collections.emptyList();
-        return Collections.enumeration(empty);
+        List<String> result = new ArrayList<String>();
+        
+        // TODO for now this returns a single value
+        final String singleType = getResponseContentType();
+        if(singleType!=null) {
+            result.add(singleType);
+        }
+        
+        return Collections.enumeration(result);
     }
 
     /**



Mime
View raw message