abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r417666 - in /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server: ResponseContext.java exceptions/AbderaServerException.java servlet/AbderaServlet.java
Date Wed, 28 Jun 2006 04:45:43 GMT
Author: eliast
Date: Tue Jun 27 21:45:43 2006
New Revision: 417666

URL: http://svn.apache.org/viewvc?rev=417666&view=rev
Log:
- Added getters/setters to response headers in ResponseContext

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java?rev=417666&r1=417665&r2=417666&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/ResponseContext.java
Tue Jun 27 21:45:43 2006
@@ -21,6 +21,7 @@
 import java.io.OutputStream;
 import java.net.URI;
 import java.util.Date;
+import java.util.Map;
 
 import javax.activation.MimeType;
 
@@ -28,21 +29,31 @@
 
   int getStatus();
   
-  String getStatusText();
+  public String getStatusText();
   
-  Date getLastModified();
+  public Date getLastModified();
   
-  String getEntityTag();
+  public String getEntityTag();
   
-  String getContentLanguage();
+  public String getContentLanguage();
   
-  URI getContentLocation();
+  public URI getContentLocation();
    
-  MimeType getContentType();
+  public MimeType getContentType();
   
-  URI getLocation();
+  public URI getLocation();
   
-  CachePolicy getCachePolicy();
+  public CachePolicy getCachePolicy();
+  
+  public void setHeader(String name, String value);
+  
+  public void addHeader(String name, String value);
+  
+  public void setHeader(String name, int value);
+  
+  public void addHeader(String name, int value);
+  
+  public Map<String, String> getHeaders();
   
   boolean hasEntity();
   

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java?rev=417666&r1=417665&r2=417666&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/exceptions/AbderaServerException.java
Tue Jun 27 21:45:43 2006
@@ -21,6 +21,7 @@
 import java.io.OutputStream;
 import java.net.URI;
 import java.util.Date;
+import java.util.Map;
 
 import javax.activation.MimeType;
 
@@ -90,4 +91,20 @@
     return false;
   }
 
+  public void addHeader(String name, int value) {
+  }
+
+  public void addHeader(String name, String value) {
+  }
+
+  public void setHeader(String name, int value) {
+  }
+
+  public void setHeader(String name, String value) {
+    
+  }
+  
+  public Map<String, String> getHeaders() {
+    return null;
+  }
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java?rev=417666&r1=417665&r2=417666&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
Tue Jun 27 21:45:43 2006
@@ -18,6 +18,7 @@
 package org.apache.abdera.server.servlet;
 
 import java.io.IOException;
+import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -82,6 +83,18 @@
       if (context.getLocation() != null)
         response.setHeader("Location", context.getLocation().toString());
       handleCachePolicy(response, context.getCachePolicy());
+      
+      // Add any custom headers after we've set the known ones,
+      // giving the developer an option to replace or set multiple
+      // headers. If they want to skip the ones above, they simply
+      // don't set them.
+      Map<String, String> headers = context.getHeaders();
+      if(headers != null) {
+        for(String header : headers.keySet()) {
+          response.setHeader(header, headers.get(header));
+        }
+      }
+      
       if (context.hasEntity())
         context.writeTo(response.getOutputStream());
     } else {



Mime
View raw message