You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/10/15 13:32:50 UTC
svn commit: r1708799 - in /tomcat/trunk/java:
javax/servlet/http/PushBuilder.java
org/apache/catalina/core/ApplicationPushBuilder.java
Author: markt
Date: Thu Oct 15 11:32:50 2015
New Revision: 1708799
URL: http://svn.apache.org/viewvc?rev=1708799&view=rev
Log:
Servlet 4.0
Complete PushBuilder interface
Still need to complete the push() implementation
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=1708799&r1=1708798&r2=1708799&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/PushBuilder.java (original)
+++ tomcat/trunk/java/javax/servlet/http/PushBuilder.java Thu Oct 15 11:32:50 2015
@@ -42,6 +42,45 @@ public interface PushBuilder {
PushBuilder method(String method);
/**
+ * Specifies the query string to use in subsequent push requests generated
+ * by a call to {@link #push()}. This will be appended to any query string
+ * specified in the call to {@link #path(String)}.
+ *
+ * @param queryString The query string to use to generate push requests
+ *
+ * @return This builder instance
+ */
+ PushBuilder queryString(String queryString);
+
+ /**
+ * Specifies the session ID to use in subsequent push requests generated
+ * by a call to {@link #push()}. The session ID will be presented the same
+ * way as it is on the original request (cookie or URL parameter). The
+ * default is determined in the following order:
+ * <ul>
+ * <li>the requested session ID for the originating request</li>
+ * <li>the session ID generated in the originated request</li>
+ * <li>{@code null}</li>
+ * </ul>
+ *
+ * @param sessionId The session ID to use to generate push requests
+ *
+ * @return This builder instance
+ */
+ PushBuilder sessionId(String sessionId);
+
+ /**
+ * Sets if the request will be conditional. If {@code true} the values from
+ * {@link #getEtag()} and {@link #getLastModified()} will be used to
+ * construct appropriate headers.
+ *
+ * @param conditional Should generated push requests be conditional
+ *
+ * @return This builder instance
+ */
+ PushBuilder conditional(boolean conditional);
+
+ /**
* Sets a HTTP header on the request. Any existing headers of the same name
* are first remove.
*
@@ -87,6 +126,28 @@ public interface PushBuilder {
PushBuilder path(String path);
/**
+ * Sets the etag to be used for conditional push requests. This will be
+ * set to {@code null} after a call to {@link #push()} so it must be
+ * explicitly set for every push request that requires it.
+ *
+ * @param etag The etag use for the push request
+ *
+ * @return This builder instance
+ */
+ PushBuilder etag(String etag);
+
+ /**
+ * Sets the last modified to be used for conditional push requests. This
+ * will be set to {@code null} after a call to {@link #push()} so it must be
+ * explicitly set for every push request that requires it.
+ *
+ * @param lastModified The last modified value to use for the push request
+ *
+ * @return This builder instance
+ */
+ PushBuilder lastModified(String lastModified);
+
+ /**
* Generates the push request. After calling this method the following
* fields are set to {@code null}:
* <ul>
@@ -110,6 +171,30 @@ public interface PushBuilder {
String getMethod();
/**
+ * Obtain the query string that will be used for push requests generated by
+ * future calls to {@code push()}.
+ *
+ * @return The query string that will be appended to push requests.
+ */
+ String getQueryString();
+
+ /**
+ * Obtain the session ID that will be used for push requests generated by
+ * future calls to {@code push()}.
+ *
+ * @return The session that will be used for push requests.
+ */
+ String getSessionId();
+
+ /**
+ * Will push requests generated by future calls to {@code push()} be
+ * conditional.
+ *
+ * @return {@code true} if push requests will be conditional
+ */
+ boolean isConditional();
+
+ /**
* @return The current set of names of HTTP headers to be used the next time
* {@code push()} is called.
*/
@@ -126,4 +211,29 @@ public interface PushBuilder {
* then any may be returned
*/
String getHeader(String name);
+
+ /**
+ * Obtain the path that will be used for the push request that will be
+ * generated by the next call to {@code push()}.
+ *
+ * @return The path value that will be associated with the next push request
+ */
+ String getPath();
+
+ /**
+ * Obtain the etag that will be used for the push request that will be
+ * generated by the next call to {@code push()}.
+ *
+ * @return The etag value that will be associated with the next push request
+ */
+ String getEtag();
+
+ /**
+ * Obtain the last modified that will be used for the push request that will
+ * be generated by the next call to {@code push()}.
+ *
+ * @return The last modified value that will be associated with the next
+ * push request
+ */
+ String getLastModified();
}
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=1708799&r1=1708798&r2=1708799&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java Thu Oct 15 11:32:50 2015
@@ -41,8 +41,13 @@ public class ApplicationPushBuilder impl
private final org.apache.coyote.Request coyoteRequest;
private String method = "GET";
- private String path;
private Map<String,List<String>> headers = new CaseInsensitiveKeyMap<>();
+ private String path;
+ private String etag;
+ private String lastModified;
+ private String queryString;
+ private String sessionId;
+ private boolean conditional;
public ApplicationPushBuilder(HttpServletRequest request) {
baseRequest = request;
@@ -92,6 +97,12 @@ public class ApplicationPushBuilder impl
@Override
+ public String getPath() {
+ return path;
+ }
+
+
+ @Override
public PushBuilder method(String method) {
this.method = method;
return this;
@@ -105,6 +116,71 @@ public class ApplicationPushBuilder impl
@Override
+ public PushBuilder etag(String etag) {
+ this.etag = etag;
+ return this;
+ }
+
+
+ @Override
+ public String getEtag() {
+ return etag;
+ }
+
+
+ @Override
+ public PushBuilder lastModified(String lastModified) {
+ this.lastModified = lastModified;
+ return this;
+ }
+
+
+ @Override
+ public String getLastModified() {
+ return lastModified;
+ }
+
+
+ @Override
+ public PushBuilder queryString(String queryString) {
+ this.queryString = queryString;
+ return this;
+ }
+
+
+ @Override
+ public String getQueryString() {
+ return queryString;
+ }
+
+
+ @Override
+ public PushBuilder sessionId(String sessionId) {
+ this.sessionId = sessionId;
+ return this;
+ }
+
+
+ @Override
+ public String getSessionId() {
+ return sessionId;
+ }
+
+
+ @Override
+ public PushBuilder conditional(boolean conditional) {
+ this.conditional = conditional;
+ return this;
+ }
+
+
+ @Override
+ public boolean isConditional() {
+ return conditional;
+ }
+
+
+ @Override
public PushBuilder addHeader(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
@@ -177,11 +253,13 @@ public class ApplicationPushBuilder impl
// TODO Copy headers
// TODO Implement other required attributes
// TODO Copy across / set other required attributes
+ // TODO Conditional request processing
coyoteRequest.action(ActionCode.PUSH_REQUEST, pushTarget);
// Reset for next call to this method
pushTarget = null;
path = null;
+ etag = null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org