Skip to content

Commit

Permalink
Servlet 4 EG made the following changes
Browse files Browse the repository at this point in the history
- etag -> eTag
- change return of push() from boolean to void

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1784806 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Feb 28, 2017
1 parent 63782c0 commit c9647ed
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 80 deletions.
19 changes: 8 additions & 11 deletions java/javax/servlet/http/PushBuilder.java
Expand Up @@ -82,7 +82,7 @@ public interface PushBuilder {

/**
* Sets if the request will be conditional. If {@code true} the values from
* {@link #getEtag()} and {@link #getLastModified()} will be used to
* {@link #getETag()} and {@link #getLastModified()} will be used to
* construct appropriate headers.
*
* @param conditional Should generated push requests be conditional
Expand Down Expand Up @@ -137,15 +137,15 @@ public interface PushBuilder {
PushBuilder path(String path);

/**
* Sets the etag to be used for conditional push requests. This will be
* 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
* @param eTag The eTag use for the push request
*
* @return This builder instance
*/
PushBuilder etag(String etag);
PushBuilder eTag(String eTag);

/**
* Sets the last modified to be used for conditional push requests. This
Expand All @@ -168,14 +168,11 @@ public interface PushBuilder {
* <li>{@code lastModified}</li>
* </ul>
*
* @return {@code true} if the push request was sent to the client,
* otherwise {@code false}
*
* @throws IllegalStateException If this method is called when {@code path}
* is {@code null}
* @throws IllegalArgumentException If the request to push requires a body
*/
boolean push();
void push();

/**
* Obtain the name of the HTTP method that will be used for push requests
Expand Down Expand Up @@ -236,12 +233,12 @@ public interface PushBuilder {
String getPath();

/**
* Obtain the etag that will be used for the push request that will be
* 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
* @return The eTag value that will be associated with the next push request
*/
String getEtag();
String getETag();

/**
* Obtain the last modified that will be used for the push request that will
Expand Down
24 changes: 10 additions & 14 deletions java/org/apache/catalina/core/ApplicationPushBuilder.java
Expand Up @@ -38,7 +38,6 @@
import org.apache.catalina.connector.Request;
import org.apache.catalina.util.SessionConfig;
import org.apache.coyote.ActionCode;
import org.apache.coyote.PushToken;
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.HexUtils;
import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
Expand All @@ -61,7 +60,7 @@ public class ApplicationPushBuilder implements PushBuilder {
private final List<Cookie> cookies = new ArrayList<>();
private String method = "GET";
private String path;
private String etag;
private String eTag;
private String lastModified;
private String queryString;
private String sessionId;
Expand Down Expand Up @@ -205,15 +204,15 @@ public String getMethod() {


@Override
public PushBuilder etag(String etag) {
this.etag = etag;
public PushBuilder eTag(String eTag) {
this.eTag = eTag;
return this;
}


@Override
public String getEtag() {
return etag;
public String getETag() {
return eTag;
}


Expand Down Expand Up @@ -323,7 +322,7 @@ public String getHeader(String name) {


@Override
public boolean push() {
public void push() {
if (path == null) {
throw new IllegalStateException(sm.getString("pushBuilder.noPath"));
}
Expand Down Expand Up @@ -382,8 +381,8 @@ public boolean push() {
}

if (conditional) {
if (etag != null) {
setHeader("if-none-match", etag);
if (eTag != null) {
setHeader("if-none-match", eTag);
} else if (lastModified != null) {
setHeader("if-modified-since", lastModified);
}
Expand All @@ -393,18 +392,15 @@ public boolean push() {
setHeader("cookie", generateCookieHeader(cookies,
catalinaRequest.getContext().getCookieProcessor()));

PushToken pushToken = new PushToken(pushTarget);
coyoteRequest.action(ActionCode.PUSH_REQUEST, pushToken);
coyoteRequest.action(ActionCode.PUSH_REQUEST, pushTarget);

// Reset for next call to this method
pushTarget = null;
path = null;
etag = null;
eTag = null;
lastModified = null;
headers.remove("if-none-match");
headers.remove("if-modified-since");

return pushToken.getResult();
}


Expand Down
8 changes: 4 additions & 4 deletions java/org/apache/coyote/AbstractProcessor.java
Expand Up @@ -482,7 +482,7 @@ public final void action(ActionCode actionCode, Object param) {
break;
}
case PUSH_REQUEST: {
doPush((PushToken) param);
doPush((Request) param);
break;
}
}
Expand Down Expand Up @@ -747,13 +747,13 @@ protected boolean isPushSupported() {
* Process a push. Processors that support push should override this method
* and process the provided token.
*
* @param pushToken Contains all the information necessary for the Processor
* to process the push request
* @param pushTarget Contains all the information necessary for the Processor
* to process the push request
*
* @throws UnsupportedOperationException if the protocol does not support
* push
*/
protected void doPush(PushToken pushToken) {
protected void doPush(Request pushTarget) {
throw new UnsupportedOperationException(
sm.getString("abstractProcessor.pushrequest.notsupported"));
}
Expand Down
44 changes: 0 additions & 44 deletions java/org/apache/coyote/PushToken.java

This file was deleted.

6 changes: 2 additions & 4 deletions java/org/apache/coyote/http2/Stream.java
Expand Up @@ -478,9 +478,9 @@ final boolean isPushSupported() {
}


final boolean push(Request request) throws IOException {
final void push(Request request) throws IOException {
if (!isPushSupported()) {
return false;
return;
}
// Set the special HTTP/2 headers
request.getMimeHeaders().addValue(":method").duplicate(request.method());
Expand All @@ -503,8 +503,6 @@ final boolean push(Request request) throws IOException {
}

push(handler, request, this);

return true;
}


Expand Down
6 changes: 3 additions & 3 deletions java/org/apache/coyote/http2/StreamProcessor.java
Expand Up @@ -24,7 +24,7 @@
import org.apache.coyote.Adapter;
import org.apache.coyote.ContainerThreadMarker;
import org.apache.coyote.ErrorState;
import org.apache.coyote.PushToken;
import org.apache.coyote.Request;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.buf.ByteChunk;
Expand Down Expand Up @@ -203,9 +203,9 @@ protected final boolean isPushSupported() {


@Override
protected final void doPush(PushToken pushToken) {
protected final void doPush(Request pushTarget) {
try {
pushToken.setResult(stream.push(pushToken.getPushTarget()));
stream.push(pushTarget);
} catch (IOException ioe) {
setErrorState(ErrorState.CLOSE_CONNECTION_NOW, ioe);
response.setErrorException(ioe);
Expand Down

0 comments on commit c9647ed

Please sign in to comment.