Author: markt
Date: Wed Oct 14 21:38:29 2015
New Revision: 1708698

URL: http://svn.apache.org/viewvc?rev=1708698&view=rev
Log:
Servlet 4.0
Add the header reading methods to PushBuilder and implement them
Note the headers are currently unused.

Modified:
    tomcat/trunk/java/javax/servlet/http/PushBuilder.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java

Modified: tomcat/trunk/java/javax/servlet/http/PushBuilder.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/PushBuilder.java?rev=1708698&r1=1708697&r2=1708698&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/PushBuilder.java (original)
+++ tomcat/trunk/java/javax/servlet/http/PushBuilder.java Wed Oct 14 21:38:29 
2015
@@ -16,6 +16,8 @@
 */
 package javax.servlet.http;
 
+import java.util.Set;
+
 /**
  * Builds a push request based on the {@link HttpServletRequest} from which 
this
  * builder was obtained. The push request will be constructed on the following
@@ -89,4 +91,22 @@ public interface PushBuilder {
      * @return This builder instance
      */
     PushBuilder removeHeader(String name);
+
+    /**
+     * @return The current set of names of HTTP headers to be used the next 
time
+     *         {@code push()} is called.
+     */
+    Set<String> getHeaderNames();
+
+    /**
+     * Obtain a value for the given HTTP header.
+     * TODO Servlet 4.0
+     * Clarify the behaviour of this method
+     *
+     * @param name  The name of the header whose value is to be returned
+     *
+     * @return The value of the given header. If multiple values are defined
+     *         then any may be returned
+     */
+    String getHeader(String name);
 }

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java?rev=1708698&r1=1708697&r2=1708698&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java Wed 
Oct 14 21:38:29 2015
@@ -17,10 +17,12 @@
 package org.apache.catalina.core;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletRequestWrapper;
@@ -125,6 +127,23 @@ public class ApplicationPushBuilder impl
 
 
     @Override
+    public Set<String> getHeaderNames() {
+        return Collections.unmodifiableSet(headers.keySet());
+    }
+
+
+    @Override
+    public String getHeader(String name) {
+        List<String> values = headers.get(name);
+        if (values == null) {
+            return null;
+        } else {
+            return values.get(0);
+        }
+    }
+
+
+    @Override
     public void push() {
         if (path == null) {
             throw new 
IllegalStateException(sm.getString("pushBuilder.noPath"));
@@ -141,6 +160,8 @@ public class ApplicationPushBuilder impl
         pushTarget.requestURI().setString(path);
         pushTarget.decodedURI().setString(path);
 
+        // TODO Copy headers
+        // TODO Implement other required attributes
         // TODO Copy across / set other required attributes
 
         coyoteRequest.action(ActionCode.PUSH_REQUEST, pushTarget);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to