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 2023/10/02 12:02:28 UTC

[tomcat] branch main updated (7ecd862b8f -> bd752fe8f1)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from 7ecd862b8f Update to Tomcat Native 2.0.6
     new 3c0791abb9 Deprecate PushBuilder as per latest Servlet 6.1
     new d28d6836b8 Remove support for HTTP/2 server push
     new bd752fe8f1 Remove the internal plumbing that supports HTTP/2 server push

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/jakarta/servlet/http/HttpServletRequest.java  |   9 +-
 .../servlet/http/HttpServletRequestWrapper.java    |   3 +
 java/jakarta/servlet/http/PushBuilder.java         |   3 +
 java/org/apache/catalina/connector/Request.java    |  19 -
 .../apache/catalina/connector/RequestFacade.java   |  14 -
 java/org/apache/catalina/connector/Response.java   |  14 -
 .../catalina/core/ApplicationHttpRequest.java      |  18 -
 .../catalina/core/ApplicationPushBuilder.java      | 427 ---------------------
 .../apache/catalina/core/LocalStrings.properties   |   5 -
 .../catalina/core/LocalStrings_fr.properties       |   5 -
 .../catalina/core/LocalStrings_ja.properties       |   5 -
 .../catalina/core/LocalStrings_ko.properties       |   5 -
 .../catalina/core/LocalStrings_zh_CN.properties    |   5 -
 .../apache/catalina/filters/RemoteIpFilter.java    |  16 -
 .../webresources/AbstractFileResourceSet.java      |  13 +-
 java/org/apache/coyote/AbstractProcessor.java      |  34 --
 java/org/apache/coyote/ActionCode.java             |  10 -
 java/org/apache/coyote/LocalStrings.properties     |   1 -
 java/org/apache/coyote/LocalStrings_fr.properties  |   1 -
 java/org/apache/coyote/LocalStrings_ja.properties  |   1 -
 java/org/apache/coyote/LocalStrings_ko.properties  |   1 -
 .../apache/coyote/LocalStrings_zh_CN.properties    |   1 -
 .../coyote/http2/ConnectionSettingsBase.java       |   3 +-
 .../coyote/http2/Http2AsyncUpgradeHandler.java     |   7 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   |  74 +---
 .../apache/coyote/http2/LocalStrings.properties    |   1 -
 .../apache/coyote/http2/LocalStrings_fr.properties |   1 -
 .../apache/coyote/http2/LocalStrings_ja.properties |   1 -
 .../apache/coyote/http2/LocalStrings_ko.properties |   1 -
 .../coyote/http2/LocalStrings_zh_CN.properties     |   1 -
 java/org/apache/coyote/http2/Stream.java           |  56 +--
 java/org/apache/coyote/http2/StreamProcessor.java  |  17 -
 .../apache/coyote/http2/StreamStateMachine.java    |   5 -
 .../catalina/core/TestApplicationPushBuilder.java  |  72 ----
 .../catalina/filters/TesterHttpServletRequest.java |   6 -
 test/org/apache/coyote/http2/Http2TestBase.java    |   8 -
 .../apache/coyote/http2/TestHttp2Section_6_5.java  |   2 -
 .../apache/coyote/http2/TestHttp2Section_6_6.java  | 127 ------
 .../org/apache/coyote/http2/TesterHttp2Parser.java |  50 ---
 webapps/docs/changelog.xml                         |  10 +
 .../WEB-INF/classes/http2/SimpleImagePush.java     |  59 ---
 webapps/examples/WEB-INF/web.xml                   |  10 -
 webapps/examples/servlets/index.html               |  11 -
 43 files changed, 46 insertions(+), 1086 deletions(-)
 delete mode 100644 java/org/apache/catalina/core/ApplicationPushBuilder.java
 delete mode 100644 test/org/apache/catalina/core/TestApplicationPushBuilder.java
 delete mode 100644 test/org/apache/coyote/http2/TestHttp2Section_6_6.java
 delete mode 100644 webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java


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


[tomcat] 02/03: Remove support for HTTP/2 server push

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit d28d6836b80d0709c56a3ab24d515788498c760e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Oct 2 11:56:41 2023 +0100

    Remove support for HTTP/2 server push
---
 java/org/apache/catalina/connector/Request.java    |  19 -
 .../apache/catalina/connector/RequestFacade.java   |  14 -
 .../catalina/core/ApplicationHttpRequest.java      |  18 -
 .../catalina/core/ApplicationPushBuilder.java      | 427 ---------------------
 .../apache/catalina/core/LocalStrings.properties   |   5 -
 .../catalina/core/LocalStrings_fr.properties       |   5 -
 .../catalina/core/LocalStrings_ja.properties       |   5 -
 .../catalina/core/LocalStrings_ko.properties       |   5 -
 .../catalina/core/LocalStrings_zh_CN.properties    |   5 -
 .../apache/catalina/filters/RemoteIpFilter.java    |  16 -
 .../catalina/core/TestApplicationPushBuilder.java  |  72 ----
 .../catalina/filters/TesterHttpServletRequest.java |   6 -
 .../apache/coyote/http2/TestHttp2Section_6_6.java  | 127 ------
 webapps/docs/changelog.xml                         |   5 +
 .../WEB-INF/classes/http2/SimpleImagePush.java     |  59 ---
 webapps/examples/WEB-INF/web.xml                   |  10 -
 webapps/examples/servlets/index.html               |  11 -
 17 files changed, 5 insertions(+), 804 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index 8e800464be..cc9a515f96 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -65,7 +65,6 @@ import jakarta.servlet.http.HttpServletResponse;
 import jakarta.servlet.http.HttpSession;
 import jakarta.servlet.http.HttpUpgradeHandler;
 import jakarta.servlet.http.Part;
-import jakarta.servlet.http.PushBuilder;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
@@ -79,7 +78,6 @@ import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ApplicationFilterChain;
 import org.apache.catalina.core.ApplicationMapping;
 import org.apache.catalina.core.ApplicationPart;
-import org.apache.catalina.core.ApplicationPushBuilder;
 import org.apache.catalina.core.ApplicationSessionCookieConfig;
 import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.catalina.mapper.MappingData;
@@ -1866,23 +1864,6 @@ public class Request implements HttpServletRequest {
     }
 
 
-    @Override
-    public PushBuilder newPushBuilder() {
-        return newPushBuilder(this);
-    }
-
-
-    public PushBuilder newPushBuilder(HttpServletRequest request) {
-        AtomicBoolean result = new AtomicBoolean();
-        coyoteRequest.action(ActionCode.IS_PUSH_SUPPORTED, result);
-        if (result.get()) {
-            return new ApplicationPushBuilder(this, request);
-        } else {
-            return null;
-        }
-    }
-
-
     @SuppressWarnings("unchecked")
     @Override
     public <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass)
diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java
index 956790888f..1a2f335076 100644
--- a/java/org/apache/catalina/connector/RequestFacade.java
+++ b/java/org/apache/catalina/connector/RequestFacade.java
@@ -40,7 +40,6 @@ import jakarta.servlet.http.HttpServletResponse;
 import jakarta.servlet.http.HttpSession;
 import jakarta.servlet.http.HttpUpgradeHandler;
 import jakarta.servlet.http.Part;
-import jakarta.servlet.http.PushBuilder;
 
 import org.apache.tomcat.util.res.StringManager;
 
@@ -573,19 +572,6 @@ public class RequestFacade implements HttpServletRequest {
     }
 
 
-    @Override
-    public PushBuilder newPushBuilder() {
-        checkFacade();
-        return request.newPushBuilder();
-    }
-
-
-    public PushBuilder newPushBuilder(HttpServletRequest request) {
-        checkFacade();
-        return this.request.newPushBuilder(request);
-    }
-
-
     @Override
     public boolean isTrailerFieldsReady() {
         checkFacade();
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 1b93479d32..14f0855b9e 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -32,19 +32,15 @@ import java.util.NoSuchElementException;
 import jakarta.servlet.DispatcherType;
 import jakarta.servlet.RequestDispatcher;
 import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletRequest;
-import jakarta.servlet.ServletRequestWrapper;
 import jakarta.servlet.http.HttpServletMapping;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletRequestWrapper;
 import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.http.PushBuilder;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Session;
-import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.util.ParameterMap;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.catalina.util.URLEncoder;
@@ -597,20 +593,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     }
 
 
-    @Override
-    public PushBuilder newPushBuilder() {
-        ServletRequest current = getRequest();
-        while (current instanceof ServletRequestWrapper) {
-            current = ((ServletRequestWrapper) current).getRequest();
-        }
-        if (current instanceof RequestFacade) {
-            return ((RequestFacade) current).newPushBuilder(this);
-        } else {
-            return null;
-        }
-    }
-
-
     // -------------------------------------------------------- Package Methods
 
     /**
diff --git a/java/org/apache/catalina/core/ApplicationPushBuilder.java b/java/org/apache/catalina/core/ApplicationPushBuilder.java
deleted file mode 100644
index 90250326ac..0000000000
--- a/java/org/apache/catalina/core/ApplicationPushBuilder.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.catalina.core;
-
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.servlet.SessionTrackingMode;
-import jakarta.servlet.http.Cookie;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.http.PushBuilder;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.authenticator.AuthenticatorBase;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.util.SessionConfig;
-import org.apache.coyote.ActionCode;
-import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.collections.CaseInsensitiveKeyMap;
-import org.apache.tomcat.util.http.CookieProcessor;
-import org.apache.tomcat.util.http.parser.HttpParser;
-import org.apache.tomcat.util.res.StringManager;
-
-public class ApplicationPushBuilder implements PushBuilder {
-
-    private static final StringManager sm = StringManager.getManager(ApplicationPushBuilder.class);
-    private static final Set<String> DISALLOWED_METHODS = new HashSet<>();
-
-    static {
-        DISALLOWED_METHODS.add("POST");
-        DISALLOWED_METHODS.add("PUT");
-        DISALLOWED_METHODS.add("DELETE");
-        DISALLOWED_METHODS.add("CONNECT");
-        DISALLOWED_METHODS.add("OPTIONS");
-        DISALLOWED_METHODS.add("TRACE");
-    }
-
-    private final HttpServletRequest baseRequest;
-    private final Request catalinaRequest;
-    private final org.apache.coyote.Request coyoteRequest;
-    private final String sessionCookieName;
-    private final String sessionPathParameterName;
-    private final boolean addSessionCookie;
-    private final boolean addSessionPathParameter;
-
-    private final Map<String,List<String>> headers = new CaseInsensitiveKeyMap<>();
-    private final List<Cookie> cookies = new ArrayList<>();
-    private String method = "GET";
-    private String path;
-    private String queryString;
-    private String sessionId;
-    private String userName;
-
-
-    public ApplicationPushBuilder(Request catalinaRequest, HttpServletRequest request) {
-
-        baseRequest = request;
-        this.catalinaRequest = catalinaRequest;
-        coyoteRequest = catalinaRequest.getCoyoteRequest();
-
-        // Populate the initial list of HTTP headers
-        Enumeration<String> headerNames = request.getHeaderNames();
-        while (headerNames.hasMoreElements()) {
-            String headerName = headerNames.nextElement();
-            List<String> values = new ArrayList<>();
-            headers.put(headerName, values);
-            Enumeration<String> headerValues = request.getHeaders(headerName);
-            while (headerValues.hasMoreElements()) {
-                values.add(headerValues.nextElement());
-            }
-        }
-
-        // Remove the headers
-        headers.remove("if-match");
-        headers.remove("if-none-match");
-        headers.remove("if-modified-since");
-        headers.remove("if-unmodified-since");
-        headers.remove("if-range");
-        headers.remove("range");
-        headers.remove("expect");
-        headers.remove("authorization");
-        headers.remove("referer");
-        // Also remove the cookie header since it will be regenerated
-        headers.remove("cookie");
-
-        // set the referer header
-        StringBuffer referer = request.getRequestURL();
-        if (request.getQueryString() != null) {
-            referer.append('?');
-            referer.append(request.getQueryString());
-        }
-        addHeader("referer", referer.toString());
-
-        // Session
-        Context context = catalinaRequest.getContext();
-        sessionCookieName = SessionConfig.getSessionCookieName(context);
-        sessionPathParameterName = SessionConfig.getSessionUriParamName(context);
-
-        HttpSession session = request.getSession(false);
-        if (session != null) {
-            sessionId = session.getId();
-        }
-        if (sessionId == null) {
-            sessionId = request.getRequestedSessionId();
-        }
-        if (!request.isRequestedSessionIdFromCookie() && !request.isRequestedSessionIdFromURL() && sessionId != null) {
-            Set<SessionTrackingMode> sessionTrackingModes =
-                    request.getServletContext().getEffectiveSessionTrackingModes();
-            addSessionCookie = sessionTrackingModes.contains(SessionTrackingMode.COOKIE);
-            addSessionPathParameter = sessionTrackingModes.contains(SessionTrackingMode.URL);
-        } else {
-            addSessionCookie = request.isRequestedSessionIdFromCookie();
-            addSessionPathParameter = request.isRequestedSessionIdFromURL();
-        }
-
-        // Cookies
-        if (request.getCookies() != null) {
-            cookies.addAll(Arrays.asList(request.getCookies()));
-        }
-        for (Cookie responseCookie : catalinaRequest.getResponse().getCookies()) {
-            if (responseCookie.getMaxAge() < 0) {
-                // Path information not available so can only remove based on
-                // name.
-                cookies.removeIf(cookie -> cookie.getName().equals(responseCookie.getName()));
-            } else {
-                cookies.add(new Cookie(responseCookie.getName(), responseCookie.getValue()));
-            }
-        }
-        if (cookies.size() > 0) {
-            List<String> cookieValues = new ArrayList<>(1);
-            cookieValues.add(generateCookieHeader(cookies, catalinaRequest.getContext().getCookieProcessor()));
-            headers.put("cookie", cookieValues);
-        }
-
-        // Authentication
-        if (catalinaRequest.getPrincipal() != null) {
-            if ((session == null) || catalinaRequest.getSessionInternal(false).getPrincipal() == null ||
-                    !(context.getAuthenticator() instanceof AuthenticatorBase) ||
-                    !((AuthenticatorBase) context.getAuthenticator()).getCache()) {
-                // Set a username only if there is no session cache for the principal
-                userName = catalinaRequest.getPrincipal().getName();
-            }
-            setHeader("authorization", "x-push");
-        }
-    }
-
-    @Override
-    public PushBuilder path(String path) {
-        if (path.startsWith("/")) {
-            this.path = path;
-        } else {
-            String contextPath = baseRequest.getContextPath();
-            int len = contextPath.length() + path.length() + 1;
-            StringBuilder sb = new StringBuilder(len);
-            sb.append(contextPath);
-            sb.append('/');
-            sb.append(path);
-            this.path = sb.toString();
-        }
-        return this;
-    }
-
-
-    @Override
-    public String getPath() {
-        return path;
-    }
-
-
-    @Override
-    public PushBuilder method(String method) {
-        String upperMethod = method.trim().toUpperCase(Locale.ENGLISH);
-        if (DISALLOWED_METHODS.contains(upperMethod) || upperMethod.length() == 0) {
-            throw new IllegalArgumentException(sm.getString("applicationPushBuilder.methodInvalid", upperMethod));
-        }
-        // Check a token was supplied
-        if (!HttpParser.isToken(upperMethod)) {
-            throw new IllegalArgumentException(sm.getString("applicationPushBuilder.methodNotToken", upperMethod));
-        }
-        this.method = method;
-        return this;
-    }
-
-
-    @Override
-    public String getMethod() {
-        return method;
-    }
-
-
-    @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 addHeader(String name, String value) {
-        headers.computeIfAbsent(name, k -> new ArrayList<>()).add(value);
-        return this;
-    }
-
-
-    @Override
-    public PushBuilder setHeader(String name, String value) {
-        List<String> values = headers.get(name);
-        if (values == null) {
-            values = new ArrayList<>();
-            headers.put(name, values);
-        } else {
-            values.clear();
-        }
-        values.add(value);
-
-        return this;
-    }
-
-
-    @Override
-    public PushBuilder removeHeader(String name) {
-        headers.remove(name);
-
-        return this;
-    }
-
-
-    @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"));
-        }
-
-        org.apache.coyote.Request pushTarget = new org.apache.coyote.Request();
-
-        pushTarget.method().setString(method);
-        // The next three are implied by the Javadoc getPath()
-        pushTarget.serverName().setString(baseRequest.getServerName());
-        pushTarget.setServerPort(baseRequest.getServerPort());
-        pushTarget.scheme().setString(baseRequest.getScheme());
-
-        // Copy headers
-        for (Map.Entry<String,List<String>> header : headers.entrySet()) {
-            for (String value : header.getValue()) {
-                pushTarget.getMimeHeaders().addValue(header.getKey()).setString(value);
-            }
-        }
-
-        // Path and query string
-        int queryIndex = path.indexOf('?');
-        String pushPath;
-        String pushQueryString = null;
-        if (queryIndex > -1) {
-            pushPath = path.substring(0, queryIndex);
-            if (queryIndex + 1 < path.length()) {
-                pushQueryString = path.substring(queryIndex + 1);
-            }
-        } else {
-            pushPath = path;
-        }
-
-        // Session ID (do this before setting the path since it may change it)
-        if (sessionId != null) {
-            if (addSessionPathParameter) {
-                pushPath = pushPath + ";" + sessionPathParameterName + "=" + sessionId;
-                pushTarget.addPathParameter(sessionPathParameterName, sessionId);
-            }
-            if (addSessionCookie) {
-                String sessionCookieHeader = sessionCookieName + "=" + sessionId;
-                MessageBytes mb = pushTarget.getMimeHeaders().getValue("cookie");
-                if (mb == null) {
-                    mb = pushTarget.getMimeHeaders().addValue("cookie");
-                    mb.setString(sessionCookieHeader);
-                } else {
-                    mb.setString(mb.getString() + ";" + sessionCookieHeader);
-                }
-            }
-        }
-
-        // Undecoded path - just %nn encoded
-        pushTarget.requestURI().setString(pushPath);
-        pushTarget.decodedURI().setString(decode(pushPath, catalinaRequest.getConnector().getURICharset()));
-
-        // Query string
-        if (pushQueryString == null && queryString != null) {
-            pushTarget.queryString().setString(queryString);
-        } else if (pushQueryString != null && queryString == null) {
-            pushTarget.queryString().setString(pushQueryString);
-        } else if (pushQueryString != null && queryString != null) {
-            pushTarget.queryString().setString(pushQueryString + "&" + queryString);
-        }
-
-        // Authorization
-        if (userName != null) {
-            pushTarget.getRemoteUser().setString(userName);
-            pushTarget.setRemoteUserNeedsAuthorization(true);
-        }
-
-        coyoteRequest.action(ActionCode.PUSH_REQUEST, pushTarget);
-
-        // Reset for next call to this method
-        path = null;
-        headers.remove("if-none-match");
-        headers.remove("if-modified-since");
-    }
-
-
-    // Package private so it can be tested. charsetName must be in lower case.
-    static String decode(String input, Charset charset) {
-        int start = input.indexOf('%');
-        int end = 0;
-
-        // Shortcut
-        if (start == -1) {
-            return input;
-        }
-
-        StringBuilder result = new StringBuilder(input.length());
-        while (start != -1) {
-            // Found the start of a %nn sequence. Copy everything from the last
-            // end to this start to the output.
-            result.append(input.substring(end, start));
-            // Advance the end 3 characters: %nn
-            end = start + 3;
-            while (end < input.length() && input.charAt(end) == '%') {
-                end += 3;
-            }
-            result.append(decodePercentSequence(input.substring(start, end), charset));
-            start = input.indexOf('%', end);
-        }
-        // Append the remaining text
-        result.append(input.substring(end));
-
-        return result.toString();
-    }
-
-
-    private static String decodePercentSequence(String sequence, Charset charset) {
-        byte[] bytes = new byte[sequence.length() / 3];
-        for (int i = 0; i < bytes.length; i += 3) {
-            bytes[i] = (byte) ((HexUtils.getDec(sequence.charAt(1 + 3 * i)) << 4) +
-                    HexUtils.getDec(sequence.charAt(2 + 3 * i)));
-        }
-
-        return new String(bytes, charset);
-    }
-
-
-    private static String generateCookieHeader(List<Cookie> cookies, CookieProcessor cookieProcessor) {
-        StringBuilder result = new StringBuilder();
-        boolean first = true;
-        for (Cookie cookie : cookies) {
-            if (first) {
-                first = false;
-            } else {
-                result.append(';');
-            }
-            // The cookie header value generated by the CookieProcessor was
-            // originally intended for the Set-Cookie header on the response.
-            // However, if passed a Cookie with just a name and value set it
-            // will generate an appropriate header for the Cookie header on the
-            // pushed request.
-            result.append(cookieProcessor.generateHeader(cookie, null));
-        }
-        return result.toString();
-    }
-}
diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties
index fd59aa65dc..d3d47814d0 100644
--- a/java/org/apache/catalina/core/LocalStrings.properties
+++ b/java/org/apache/catalina/core/LocalStrings.properties
@@ -60,9 +60,6 @@ applicationFilterRegistration.nullInitParams=Unable to set initialisation parame
 
 applicationHttpRequest.fragmentInDispatchPath=The fragment in dispatch path [{0}] has been removed
 
-applicationPushBuilder.methodInvalid=The HTTP method for a push request must be both cacheable and safe but [{0}] is not
-applicationPushBuilder.methodNotToken=HTTP methods must be tokens but [{0}] contains a non-token character
-
 applicationServletRegistration.setServletSecurity.iae=Null constraint specified for servlet [{0}] deployed to context with name [{1}]
 applicationServletRegistration.setServletSecurity.ise=Security constraints can''t be added to servlet [{0}] deployed to context with name [{1}] as the context has already been initialised
 
@@ -162,8 +159,6 @@ naming.wsdlFailed=Failed to find wsdl file: [{0}]
 
 noPluggabilityServletContext.notAllowed=Section 4.4 of the Servlet 3.0 specification does not permit this method to be called from a ServletContextListener that was not defined in web.xml, a web-fragment.xml file nor annotated with @WebListener
 
-pushBuilder.noPath=It is illegal to call push() before setting a path
-
 propertiesRoleMappingListener.roleMappingFileNull=Role mapping file cannot be null
 propertiesRoleMappingListener.roleMappingFileEmpty=Role mapping file cannot be empty
 propertiesRoleMappingListener.roleMappingFileFail=Failed to load role mapping file [{0}]
diff --git a/java/org/apache/catalina/core/LocalStrings_fr.properties b/java/org/apache/catalina/core/LocalStrings_fr.properties
index f77785045b..cd627970f9 100644
--- a/java/org/apache/catalina/core/LocalStrings_fr.properties
+++ b/java/org/apache/catalina/core/LocalStrings_fr.properties
@@ -60,9 +60,6 @@ applicationFilterRegistration.nullInitParams=Impossible de fixer les paramètres
 
 applicationHttpRequest.fragmentInDispatchPath=Le fragment dans le chemin de dispatch [{0}] a été enlevé
 
-applicationPushBuilder.methodInvalid=La méthode HTTP pour une requête push doit être à la fois être sans danger et pouvoir être mise en cache, mais [{0}] ne correspond pas
-applicationPushBuilder.methodNotToken=Les méthodes HTTP doivent être des "token", mais [{0}] contient un caractère invalide dans un token.
-
 applicationServletRegistration.setServletSecurity.iae=Contrainte nulle spécifiée pour le Servlet [{0}] déployé dans le contexte avec le nom [{1}]
 applicationServletRegistration.setServletSecurity.ise=Les contraintes de sécurité ne peuvent pas être ajoutées au Servlet [{0}] déployé dans le contexte [{1}] car le contexte a déjà été initialisé
 
@@ -168,8 +165,6 @@ propertiesRoleMappingListener.roleMappingFileEmpty=Le fichier d'association de r
 propertiesRoleMappingListener.roleMappingFileFail=Erreur de chargement du fichier d''association de rôles [{0}]
 propertiesRoleMappingListener.roleMappingFileNull=Le fichier d'association de rôles ne peut être null
 
-pushBuilder.noPath=Il est interdit d'appeler push() avant de fixer un chemin
-
 standardContext.applicationListener=Erreur lors de la configuration de la classe d''écoute de l''application (application listener) [{0}]
 standardContext.applicationSkipped=L'installation des écouteurs (listeners) de l'application a été sautée suite aux erreurs précédentes
 standardContext.backgroundProcess.instanceManager=Exception lors du traitement d''arrière plan du gestionnaire d''instances [{0}]
diff --git a/java/org/apache/catalina/core/LocalStrings_ja.properties b/java/org/apache/catalina/core/LocalStrings_ja.properties
index 40006c8836..7faf8abedc 100644
--- a/java/org/apache/catalina/core/LocalStrings_ja.properties
+++ b/java/org/apache/catalina/core/LocalStrings_ja.properties
@@ -60,9 +60,6 @@ applicationFilterRegistration.nullInitParams=キー [{0}] または値 [{1}] の
 
 applicationHttpRequest.fragmentInDispatchPath=ディスパッチパス [{0}] 中のフラグメントは除去されました
 
-applicationPushBuilder.methodInvalid=プッシュリクエストの HTTP メソッドはキャッシュ可能、かつ、安全でなければなりません。[{0}] は指定できません。
-applicationPushBuilder.methodNotToken=HTTP メソッド [{0}] にトークンとして利用できない文字が含まれています。
-
 applicationServletRegistration.setServletSecurity.iae=サーブレット [{0}] に指定されたNULL制約が、名前 [{1}] のコンテキストに配備されました
 applicationServletRegistration.setServletSecurity.ise=コンテキストが既に初期化されているため、名前 [{1}] のコンテキストに配備されたサーブレット [{0}] にセキュリティ制約を追加できません
 
@@ -168,8 +165,6 @@ propertiesRoleMappingListener.roleMappingFileEmpty=ロール マッピング フ
 propertiesRoleMappingListener.roleMappingFileFail=ロール マッピング ファイル [{0}] のロードに失敗しました
 propertiesRoleMappingListener.roleMappingFileNull=ロール マッピング ファイルを null にすることはできません
 
-pushBuilder.noPath=path を設定する前に push() を呼び出すことはできません。
-
 standardContext.applicationListener=クラス [{0}] のアプリケーションリスナの設定中にエラーが発生しました
 standardContext.applicationSkipped=前のエラーのためにアプリケーションリスナのインストールをスキップします
 standardContext.backgroundProcess.instanceManager=インスタンスマネージャ [{0}] のバックグラウンドプロセス処理中の例外
diff --git a/java/org/apache/catalina/core/LocalStrings_ko.properties b/java/org/apache/catalina/core/LocalStrings_ko.properties
index 6d735f15cb..6ed9a1005d 100644
--- a/java/org/apache/catalina/core/LocalStrings_ko.properties
+++ b/java/org/apache/catalina/core/LocalStrings_ko.properties
@@ -60,9 +60,6 @@ applicationFilterRegistration.nullInitParams=널인 이름 또는 값 때문에,
 
 applicationHttpRequest.fragmentInDispatchPath=디스패치 경로 [{0}](으)로부터 URI fragment를 제거했습니다.
 
-applicationPushBuilder.methodInvalid=PUSH 요청을 위한 HTTP 메소드는 반드시 캐시 가능하고 안전해야 하는데, [{0}]은(는) 그렇지 않습니다.
-applicationPushBuilder.methodNotToken=HTTP 메소드들은 토큰들이어야 하지만, [{0}]은(는) 토큰이 아닌 문자를 포함하고 있습니다.
-
 applicationServletRegistration.setServletSecurity.iae=[{1}](이)라는 이름의 컨텍스트에 배치된 서블릿 [{0}]을(를) 위해, 널 constraint가 지정되었습니다.
 applicationServletRegistration.setServletSecurity.ise=컨텍스트가 이미 초기화되었기에, [{1}](이)라는 이름의 컨텍스트에 배치된 서블릿 [{0}]에 security constraint들이 추가될 수 없습니다.
 
@@ -159,8 +156,6 @@ naming.wsdlFailed=wsdl 파일을 찾지 못했습니다: [{0}]
 
 noPluggabilityServletContext.notAllowed=Servlet 3.0 스펙의 4.4 장에 따르면, web.xml 또는 web-fragment.xml 파일에 정의되지 않거나 @WebListener로 annotate되지 않은, ServletContextListener에서 이 메소드를 호출하는 것은 허용되지 않습니다.
 
-pushBuilder.noPath=경로를 설정하기 전에 push()를 호출하는 것은 불허됩니다.
-
 standardContext.applicationListener=클래스 [{0}]의 애플리케이션 리스너를 설정하는 중 오류 발생
 standardContext.applicationSkipped=이전 오류(들)로 인하여, 애플리케이션 리스너들을 설치하는 것을 건너뛰었습니다.
 standardContext.backgroundProcess.instanceManager=인스턴스 매니저 [{0}]을(를) 백그라운드 프로세스에서 처리 중 예외 발생
diff --git a/java/org/apache/catalina/core/LocalStrings_zh_CN.properties b/java/org/apache/catalina/core/LocalStrings_zh_CN.properties
index 1ce8fc779b..534134732a 100644
--- a/java/org/apache/catalina/core/LocalStrings_zh_CN.properties
+++ b/java/org/apache/catalina/core/LocalStrings_zh_CN.properties
@@ -61,9 +61,6 @@ applicationFilterRegistration.nullInitParams=由于name和(或)value为null,
 
 applicationHttpRequest.fragmentInDispatchPath=调度路径[{0}]中的片段已被删除
 
-applicationPushBuilder.methodInvalid=推送请求的HTTP方法必须既可缓存又安全,但是[{0}]不是
-applicationPushBuilder.methodNotToken=HTTP方法必须是令牌(token),但 [{0}] 包含非令牌字符
-
 applicationServletRegistration.setServletSecurity.iae=为部署到名为[{1}]的上下文的Servlet[{0}]指定的空约束
 applicationServletRegistration.setServletSecurity.ise=无法将安全性约束添加到已部署到名称为[{1}]的上下文的servlet [{0}]中,因为上下文已被初始化
 
@@ -164,8 +161,6 @@ propertiesRoleMappingListener.roleMappingFileEmpty=角色映射文件不能为
 propertiesRoleMappingListener.roleMappingFileFail=加载角色映射文件[{0}]失败
 propertiesRoleMappingListener.roleMappingFileNull=角色映射文件不能为NULL
 
-pushBuilder.noPath=在设置路径之前调用push()是非法的
-
 standardContext.applicationListener=配置应用程序监听器[{0}]错误
 standardContext.applicationSkipped=由于以前的错误,已跳过安装应用程序侦听器
 standardContext.backgroundProcess.instanceManager=异常处理实例管理器[{0}]后台进程
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java
index 13a0eb7bf9..038f4a95b7 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -34,16 +34,13 @@ import jakarta.servlet.FilterChain;
 import jakarta.servlet.GenericFilter;
 import jakarta.servlet.ServletException;
 import jakarta.servlet.ServletRequest;
-import jakarta.servlet.ServletRequestWrapper;
 import jakarta.servlet.ServletResponse;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletRequestWrapper;
 import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.PushBuilder;
 
 import org.apache.catalina.AccessLog;
 import org.apache.catalina.Globals;
-import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -640,19 +637,6 @@ public class RemoteIpFilter extends GenericFilter {
         public StringBuffer getRequestURL() {
             return RequestUtil.getRequestURL(this);
         }
-
-        @Override
-        public PushBuilder newPushBuilder() {
-            ServletRequest current = getRequest();
-            while (current instanceof ServletRequestWrapper) {
-                current = ((ServletRequestWrapper) current).getRequest();
-            }
-            if (current instanceof RequestFacade) {
-                return ((RequestFacade) current).newPushBuilder(this);
-            } else {
-                return null;
-            }
-        }
     }
 
 
diff --git a/test/org/apache/catalina/core/TestApplicationPushBuilder.java b/test/org/apache/catalina/core/TestApplicationPushBuilder.java
deleted file mode 100644
index e939084b64..0000000000
--- a/test/org/apache/catalina/core/TestApplicationPushBuilder.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.catalina.core;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestApplicationPushBuilder {
-
-    @Test
-    public void test01() {
-        doTest("foo", StandardCharsets.UTF_8, "foo");
-    }
-
-    @Test
-    public void test02() {
-        doTest("/foo", StandardCharsets.UTF_8, "/foo");
-    }
-
-    @Test
-    public void test03() {
-        doTest("%20foo", StandardCharsets.UTF_8, " foo");
-    }
-
-    @Test
-    public void test04() {
-        doTest("fo%20o", StandardCharsets.UTF_8, "fo o");
-    }
-
-    @Test
-    public void test05() {
-        doTest("foo%20", StandardCharsets.UTF_8, "foo ");
-    }
-
-    @Test
-    public void test06() {
-        doTest("%21foo", StandardCharsets.UTF_8, "!foo");
-    }
-
-    @Test
-    public void test07() {
-        doTest("fo%21o", StandardCharsets.UTF_8, "fo!o");
-    }
-
-    @Test
-    public void test08() {
-        doTest("foo%21", StandardCharsets.UTF_8, "foo!");
-    }
-
-
-    private void doTest(String input, Charset charset, String expected) {
-        String result = ApplicationPushBuilder.decode(input, charset);
-        Assert.assertEquals(expected, result);
-    }
-}
diff --git a/test/org/apache/catalina/filters/TesterHttpServletRequest.java b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
index 449963e6ec..e03737b83a 100644
--- a/test/org/apache/catalina/filters/TesterHttpServletRequest.java
+++ b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
@@ -45,7 +45,6 @@ import jakarta.servlet.http.HttpServletResponse;
 import jakarta.servlet.http.HttpSession;
 import jakarta.servlet.http.HttpUpgradeHandler;
 import jakarta.servlet.http.Part;
-import jakarta.servlet.http.PushBuilder;
 
 public class TesterHttpServletRequest implements HttpServletRequest {
 
@@ -431,11 +430,6 @@ public class TesterHttpServletRequest implements HttpServletRequest {
         throw new RuntimeException("Not implemented");
     }
 
-    @Override
-    public PushBuilder newPushBuilder() {
-        throw new RuntimeException("Not implemented");
-    }
-
     @Override
     public boolean isTrailerFieldsReady() {
         throw new RuntimeException("Not implemented");
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_6.java b/test/org/apache/coyote/http2/TestHttp2Section_6_6.java
deleted file mode 100644
index ae61fd31f1..0000000000
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_6.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.coyote.http2;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.PushBuilder;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-
-/**
- * Unit tests for Section 6.5 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- */
-public class TestHttp2Section_6_6 extends Http2TestBase {
-
-
-    @Test
-    public void testPushPromise() throws Exception {
-        http2Connect();
-
-        // Build the push request
-        byte[] frameHeader = new byte[9];
-        ByteBuffer headersPayload = ByteBuffer.allocate(128);
-
-        List<Header> headers = new ArrayList<>(4);
-        headers.add(new Header(":method", "GET"));
-        headers.add(new Header(":scheme", "http"));
-        headers.add(new Header(":path", "/push"));
-        headers.add(new Header(":authority", "localhost:" + getPort()));
-
-        buildGetRequest(frameHeader, headersPayload, null, headers, 3);
-
-        // Send the request
-        writeFrame(frameHeader, headersPayload);
-
-        // Read the response
-        // push promise
-        parser.readFrame();
-        // stream 3 response headers
-        parser.readFrame();
-        // stream 3 response body
-        parser.readFrame();
-        // stream 2 response headers
-        parser.readFrame();
-        // stream 2 response body
-        parser.readFrame();
-
-        String trace = output.getTrace();
-
-        Assert.assertTrue(trace, trace.contains("3-PushPromise-2"));
-        Assert.assertTrue(trace, trace.contains("2-Header-[:status]-[200]"));
-        Assert.assertTrue(trace, trace.contains("2-Body-8192"));
-        Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[200]"));
-        Assert.assertTrue(trace, trace.contains("3-Body-1024"));
-    }
-
-
-    @Override
-    protected void configureAndStartWebApplication() throws LifecycleException {
-        Tomcat tomcat = getTomcatInstance();
-
-        Context ctxt = tomcat.addContext("", null);
-
-        Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
-        ctxt.addServletMappingDecoded("/simple", "simple");
-
-        Tomcat.addServlet(ctxt, "push", new PushServlet());
-        ctxt.addServletMappingDecoded("/push", "push");
-
-        tomcat.start();
-    }
-
-
-    private static class PushServlet extends HttpServlet {
-
-        private static final long serialVersionUID = 1L;
-
-        @Override
-        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-            PushBuilder pb = req.newPushBuilder();
-            pb.path("/simple").push();
-
-            // Generate content with a simple known format.
-            resp.setContentType("application/octet-stream");
-
-            int count = 512;
-
-            // Two bytes per entry (1k data)
-            resp.setContentLengthLong(count * 2);
-
-            OutputStream os = resp.getOutputStream();
-            byte[] data = new byte[2];
-            for (int i = 0; i < count; i++) {
-                data[0] = (byte) (i & 0xFF);
-                data[1] = (byte) ((i >> 8) & 0xFF);
-                os.write(data);
-            }
-        }
-    }
-}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 0addab5e1f..9b1c426bfd 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -165,6 +165,11 @@
         for the Servlet 6.1 specification. It will be replaced in a future
         Tomcat 11 milestone with support for 103 early hints. (markt)
       </update>
+      <update>
+        Remove support for HTTP/2 server push. Calls to
+        <code>newPushBuilder()</code> will always return <code>null</code>.
+        (markt)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Jasper">
diff --git a/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java b/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
deleted file mode 100644
index 3da6895904..0000000000
--- a/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package http2;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.PushBuilder;
-
-public class SimpleImagePush extends HttpServlet {
-
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-            throws ServletException, IOException {
-
-        resp.setCharacterEncoding("UTF-8");
-        resp.setContentType("text/html");
-        PrintWriter pw = resp.getWriter();
-
-        PushBuilder pb = req.newPushBuilder();
-        if (pb != null) {
-            pb.path("servlets/images/code.gif");
-            pb.push();
-            pw.println("<html>");
-            pw.println("<body>");
-            pw.println("<p>The following image was provided via a push request.</p>");
-            pw.println("<img src=\"" + getServletContext().getContextPath() + "/servlets/images/code.gif\"/>");
-            pw.println("</body>");
-            pw.println("</html>");
-            pw.flush();
-        } else {
-            pw.println("<html>");
-            pw.println("<body>");
-            pw.println("<p>Server push requests are not supported by this protocol.</p>");
-            pw.println("</body>");
-            pw.println("</html>");
-        }
-    }
-}
diff --git a/webapps/examples/WEB-INF/web.xml b/webapps/examples/WEB-INF/web.xml
index 12d865ef2d..442aa032e8 100644
--- a/webapps/examples/WEB-INF/web.xml
+++ b/webapps/examples/WEB-INF/web.xml
@@ -383,16 +383,6 @@
       <url-pattern>/servlets/nonblocking/numberwriter</url-pattern>
     </servlet-mapping>
 
-    <!-- Server Push examples -->
-    <servlet>
-      <servlet-name>simpleimagepush</servlet-name>
-      <servlet-class>http2.SimpleImagePush</servlet-class>
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>simpleimagepush</servlet-name>
-      <url-pattern>/servlets/serverpush/simpleimage</url-pattern>
-    </servlet-mapping>
-
     <!-- Trailer examples -->
     <servlet>
       <servlet-name>responsetrailer</servlet-name>
diff --git a/webapps/examples/servlets/index.html b/webapps/examples/servlets/index.html
index d07a277e9c..5a36096d17 100644
--- a/webapps/examples/servlets/index.html
+++ b/webapps/examples/servlets/index.html
@@ -165,17 +165,6 @@ for clarity.</p>
   <td style="width: 30%;"></td>
 </tr>
 
-<tr>
-  <th colspan="3">Servlet 4.0 Server Push examples</th>
-</tr>
-<tr>
-  <td>Simple image push</td>
-  <td style="width: 30%;">
-    <a href="serverpush/simpleimage"><img src="images/execute.gif" alt=""> Execute</a>
-  </td>
-  <td style="width: 30%;"></td>
-</tr>
-
 <tr>
   <th colspan="3">Servlet 4.0 Trailer Field examples</th>
 </tr>


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


[tomcat] 03/03: Remove the internal plumbing that supports HTTP/2 server push

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit bd752fe8f1b8759748989437b1d29e1451227b0d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Oct 2 12:15:41 2023 +0100

    Remove the internal plumbing that supports HTTP/2 server push
---
 java/org/apache/catalina/connector/Response.java   | 14 ----
 .../webresources/AbstractFileResourceSet.java      | 13 ++--
 java/org/apache/coyote/AbstractProcessor.java      | 34 ----------
 java/org/apache/coyote/ActionCode.java             | 10 ---
 java/org/apache/coyote/LocalStrings.properties     |  1 -
 java/org/apache/coyote/LocalStrings_fr.properties  |  1 -
 java/org/apache/coyote/LocalStrings_ja.properties  |  1 -
 java/org/apache/coyote/LocalStrings_ko.properties  |  1 -
 .../apache/coyote/LocalStrings_zh_CN.properties    |  1 -
 .../coyote/http2/ConnectionSettingsBase.java       |  3 +-
 .../coyote/http2/Http2AsyncUpgradeHandler.java     |  7 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 74 ++--------------------
 .../apache/coyote/http2/LocalStrings.properties    |  1 -
 .../apache/coyote/http2/LocalStrings_fr.properties |  1 -
 .../apache/coyote/http2/LocalStrings_ja.properties |  1 -
 .../apache/coyote/http2/LocalStrings_ko.properties |  1 -
 .../coyote/http2/LocalStrings_zh_CN.properties     |  1 -
 java/org/apache/coyote/http2/Stream.java           | 56 ++--------------
 java/org/apache/coyote/http2/StreamProcessor.java  | 17 -----
 .../apache/coyote/http2/StreamStateMachine.java    |  5 --
 test/org/apache/coyote/http2/Http2TestBase.java    |  8 ---
 .../apache/coyote/http2/TestHttp2Section_6_5.java  |  2 -
 .../org/apache/coyote/http2/TesterHttp2Parser.java | 50 ---------------
 23 files changed, 24 insertions(+), 279 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index bc6cf0bba8..e2e983b7f6 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -139,12 +139,6 @@ public class Response implements HttpServletResponse {
     protected final CharChunk redirectURLCC = new CharChunk();
 
 
-    /*
-     * Not strictly required but it makes generating HTTP/2 push requests a lot easier if these are retained until the
-     * response is recycled.
-     */
-    private final List<Cookie> cookies = new ArrayList<>();
-
     private HttpServletResponse applicationResponse = null;
 
 
@@ -183,7 +177,6 @@ public class Response implements HttpServletResponse {
      */
     public void recycle() {
 
-        cookies.clear();
         outputBuffer.recycle();
         usingOutputStream = false;
         usingWriter = false;
@@ -212,11 +205,6 @@ public class Response implements HttpServletResponse {
     }
 
 
-    public List<Cookie> getCookies() {
-        return cookies;
-    }
-
-
     // ------------------------------------------------------- Response Methods
 
     /**
@@ -896,8 +884,6 @@ public class Response implements HttpServletResponse {
             return;
         }
 
-        cookies.add(cookie);
-
         String header = generateCookieString(cookie);
         // if we reached here, no exception, cookie is valid
         addHeader("Set-Cookie", header, getContext().getCookieProcessor().getCharset());
diff --git a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
index 7a81b943b0..bdf51a5821 100644
--- a/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
+++ b/java/org/apache/catalina/webresources/AbstractFileResourceSet.java
@@ -99,13 +99,12 @@ public abstract class AbstractFileResourceSet extends AbstractResourceSet {
             return null;
         }
 
-        // Ensure that the file is not outside the fileBase. This should not be
-        // possible for standard requests (the request is normalized early in
-        // the request processing) but might be possible for some access via the
-        // Servlet API (RequestDispatcher, HTTP/2 push etc.) therefore these
-        // checks are retained as an additional safety measure
-        // absoluteBase has been normalized so absPath needs to be normalized as
-        // well.
+        /*
+         * Ensure that the file is not outside the fileBase. This should not be possible for standard requests (the
+         * request is normalized early in the request processing) but might be possible for some access via the Servlet
+         * API (e.g. RequestDispatcher) therefore these checks are retained as an additional safety measure absoluteBase
+         * has been normalized so absPath needs to be normalized as well.
+         */
         String absPath = normalize(file.getAbsolutePath());
         if (absPath == null || absoluteBase.length() > absPath.length()) {
             return null;
diff --git a/java/org/apache/coyote/AbstractProcessor.java b/java/org/apache/coyote/AbstractProcessor.java
index e1f2347da4..4e26dca6e5 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -608,17 +608,6 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement
                 break;
             }
 
-            // Servlet 4.0 Push requests
-            case IS_PUSH_SUPPORTED: {
-                AtomicBoolean result = (AtomicBoolean) param;
-                result.set(isPushSupported());
-                break;
-            }
-            case PUSH_REQUEST: {
-                doPush((Request) param);
-                break;
-            }
-
             // Servlet 4.0 Trailers
             case IS_TRAILER_FIELDS_READY: {
                 AtomicBoolean result = (AtomicBoolean) param;
@@ -930,29 +919,6 @@ public abstract class AbstractProcessor extends AbstractProcessorLight implement
     }
 
 
-    /**
-     * Protocols that support push should override this method and return {@code
-     * true}.
-     *
-     * @return {@code true} if push is supported by this processor, otherwise {@code false}.
-     */
-    protected boolean isPushSupported() {
-        return false;
-    }
-
-
-    /**
-     * Process a push. Processors that support push should override this method and process the provided token.
-     *
-     * @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(Request pushTarget) {
-        throw new UnsupportedOperationException(sm.getString("abstractProcessor.pushrequest.notsupported"));
-    }
-
-
     protected abstract boolean isTrailerFieldsReady();
 
 
diff --git a/java/org/apache/coyote/ActionCode.java b/java/org/apache/coyote/ActionCode.java
index 308d3b3eee..94c2933353 100644
--- a/java/org/apache/coyote/ActionCode.java
+++ b/java/org/apache/coyote/ActionCode.java
@@ -232,16 +232,6 @@ public enum ActionCode {
      */
     DISPATCH_EXECUTE,
 
-    /**
-     * Is server push supported and allowed for the current request?
-     */
-    IS_PUSH_SUPPORTED,
-
-    /**
-     * Push a request on behalf of the client of the current request.
-     */
-    PUSH_REQUEST,
-
     /**
      * Are the request trailer fields ready to be read? Note that this returns true if it is known that request trailer
      * fields are not supported so an empty collection of trailers can then be read.
diff --git a/java/org/apache/coyote/LocalStrings.properties b/java/org/apache/coyote/LocalStrings.properties
index e99009cf3b..36198bb0aa 100644
--- a/java/org/apache/coyote/LocalStrings.properties
+++ b/java/org/apache/coyote/LocalStrings.properties
@@ -30,7 +30,6 @@ abstractProcessor.fallToDebug=\n\
 abstractProcessor.hostInvalid=The host [{0}] is not valid
 abstractProcessor.httpupgrade.notsupported=HTTP upgrade is not supported by this protocol
 abstractProcessor.noExecute=Unable to transfer processing to a container thread because this Processor is not currently associated with a SocketWrapper
-abstractProcessor.pushrequest.notsupported=Server push requests are not supported by this protocol
 abstractProcessor.setErrorState=Error state [{0}] reported while processing request
 abstractProcessor.socket.ssl=Exception getting SSL attributes
 
diff --git a/java/org/apache/coyote/LocalStrings_fr.properties b/java/org/apache/coyote/LocalStrings_fr.properties
index 73186e386b..f036c73130 100644
--- a/java/org/apache/coyote/LocalStrings_fr.properties
+++ b/java/org/apache/coyote/LocalStrings_fr.properties
@@ -30,7 +30,6 @@ abstractProcessor.fallToDebug=\n\
 abstractProcessor.hostInvalid=L''hôte [{0}] n''est pas valide
 abstractProcessor.httpupgrade.notsupported=La promotion (upgrade) HTTP n'est pas supporté par ce protocole
 abstractProcessor.noExecute=Impossible de transférer l'exécution à un thread du conteneur parce que ce processeur n'est pas associé à un SocketWrapper
-abstractProcessor.pushrequest.notsupported=Le requêtes push du serveur ne sont pas supportées par ce protocole
 abstractProcessor.setErrorState=Etat d''erreur [{0}] lors du traitement de la requête
 abstractProcessor.socket.ssl=Exception lors de l'obtention des attributs SSL
 
diff --git a/java/org/apache/coyote/LocalStrings_ja.properties b/java/org/apache/coyote/LocalStrings_ja.properties
index d3b3d93fd6..0babfe65d5 100644
--- a/java/org/apache/coyote/LocalStrings_ja.properties
+++ b/java/org/apache/coyote/LocalStrings_ja.properties
@@ -30,7 +30,6 @@ abstractProcessor.fallToDebug=\n\
 abstractProcessor.hostInvalid=ホスト名 [{0}] は無効です。
 abstractProcessor.httpupgrade.notsupported=このプロトコルは HTTP アップグレードに対応していません。
 abstractProcessor.noExecute=このプロセッサが現在 SocketWrapper に関連付けられていないため、コンテナスレッドに処理を転送できません
-abstractProcessor.pushrequest.notsupported=このプロトコルはサーバープッシュの要求に対応していません。
 abstractProcessor.setErrorState=リクエストの処理中にエラー状態[{0}]が報告されました
 abstractProcessor.socket.ssl=SSL属性取得時の例外
 
diff --git a/java/org/apache/coyote/LocalStrings_ko.properties b/java/org/apache/coyote/LocalStrings_ko.properties
index b57ade3185..400fd84d69 100644
--- a/java/org/apache/coyote/LocalStrings_ko.properties
+++ b/java/org/apache/coyote/LocalStrings_ko.properties
@@ -30,7 +30,6 @@ abstractProcessor.fallToDebug=\n\
 abstractProcessor.hostInvalid=호스트 [{0}]은(는) 유효하지 않습니다.
 abstractProcessor.httpupgrade.notsupported=HTTP 업그레이드는 이 프로토콜에 의해 지원되지 않습니다.
 abstractProcessor.noExecute=이 프로세서가 현재 SocketWrapper와 연관되어 있지 않기 때문에, 처리 작업을 컨테이너 쓰레드로 이관할 수 없습니다.
-abstractProcessor.pushrequest.notsupported=이 프로토콜은 서버 push 요청들을 지원하지 않습니다.
 abstractProcessor.setErrorState=요청 처리 중 오류 상태 [{0}]이(가) 보고됨.
 abstractProcessor.socket.ssl=SSL 속성들을 얻으려는 중 예외 발생
 
diff --git a/java/org/apache/coyote/LocalStrings_zh_CN.properties b/java/org/apache/coyote/LocalStrings_zh_CN.properties
index a5c07b33b7..120b2e6ded 100644
--- a/java/org/apache/coyote/LocalStrings_zh_CN.properties
+++ b/java/org/apache/coyote/LocalStrings_zh_CN.properties
@@ -30,7 +30,6 @@ abstractProcessor.fallToDebug=\n\
 abstractProcessor.hostInvalid=[{0}] 是无效主机
 abstractProcessor.httpupgrade.notsupported=此协议不支持HTTP升级(upgrade)。
 abstractProcessor.noExecute=无法将处理传输到容器线程,因为此处理器当前未与SocketWrapper关联
-abstractProcessor.pushrequest.notsupported=此协议不支持服务器推送请求
 abstractProcessor.setErrorState=正在处理请求时出现错误状态[{0}]
 abstractProcessor.socket.ssl=获取SSL属性异常
 
diff --git a/java/org/apache/coyote/http2/ConnectionSettingsBase.java b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
index eea078417c..2ae2e8e563 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsBase.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
@@ -39,7 +39,6 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
 
     // Defaults (defined by the specification)
     static final int DEFAULT_HEADER_TABLE_SIZE = Hpack.DEFAULT_TABLE_SIZE;
-    static final boolean DEFAULT_ENABLE_PUSH = true;
     static final long DEFAULT_MAX_CONCURRENT_STREAMS = UNLIMITED;
     static final int DEFAULT_INITIAL_WINDOW_SIZE = (1 << 16) - 1;
     static final int DEFAULT_MAX_FRAME_SIZE = MIN_MAX_FRAME_SIZE;
@@ -56,7 +55,7 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
         this.connectionId = connectionId;
         // Set up the defaults
         current.put(Setting.HEADER_TABLE_SIZE, Long.valueOf(DEFAULT_HEADER_TABLE_SIZE));
-        current.put(Setting.ENABLE_PUSH, Long.valueOf(DEFAULT_ENABLE_PUSH ? 1 : 0));
+        current.put(Setting.ENABLE_PUSH, Long.valueOf(0));
         current.put(Setting.MAX_CONCURRENT_STREAMS, Long.valueOf(DEFAULT_MAX_CONCURRENT_STREAMS));
         current.put(Setting.INITIAL_WINDOW_SIZE, Long.valueOf(DEFAULT_INITIAL_WINDOW_SIZE));
         current.put(Setting.MAX_FRAME_SIZE, Long.valueOf(DEFAULT_MAX_FRAME_SIZE));
diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
index d551bbc6ab..138529c706 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -195,12 +195,11 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler {
 
 
     @Override
-    void writeHeaders(Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)
-            throws IOException {
+    void writeHeaders(Stream stream, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize) throws IOException {
         headerWriteLock.lock();
         try {
-            AsyncHeaderFrameBuffers headerFrameBuffers = (AsyncHeaderFrameBuffers) doWriteHeaders(stream,
-                    pushedStreamId, mimeHeaders, endOfStream, payloadSize);
+            AsyncHeaderFrameBuffers headerFrameBuffers = (AsyncHeaderFrameBuffers) doWriteHeaders(stream, mimeHeaders,
+                    endOfStream, payloadSize);
             if (headerFrameBuffers != null) {
                 socketWrapper.write(BlockingMode.SEMI_BLOCK, protocol.getWriteTimeout(), TimeUnit.MILLISECONDS, null,
                         SocketWrapperBase.COMPLETE_WRITE, applicationErrorCompletion,
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 389c2273a5..55746d1520 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -121,7 +121,6 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
     // Start at -1 so the 'add 2' logic in closeIdleStreams() works
     private volatile int maxActiveRemoteStreamId = -1;
     private volatile int maxProcessedStreamId;
-    private final AtomicInteger nextLocalStreamId = new AtomicInteger(2);
     private final PingManager pingManager = getPingManager();
     private volatile int newStreamsSinceLastPrune = 0;
     private final Set<Stream> backLogStreams = new HashSet<>();
@@ -698,13 +697,13 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
         }
     }
 
-    void writeHeaders(Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)
+    void writeHeaders(Stream stream, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)
             throws IOException {
         // This ensures the Stream processing thread has control of the socket.
         Lock lock = socketWrapper.getLock();
         lock.lock();
         try {
-            doWriteHeaders(stream, pushedStreamId, mimeHeaders, endOfStream, payloadSize);
+            doWriteHeaders(stream, mimeHeaders, endOfStream, payloadSize);
         } finally {
             lock.unlock();
         }
@@ -719,17 +718,12 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
      * Separate method to allow Http2AsyncUpgradeHandler to call this code without synchronizing on socketWrapper since
      * it doesn't need to.
      */
-    protected HeaderFrameBuffers doWriteHeaders(Stream stream, int pushedStreamId, MimeHeaders mimeHeaders,
-            boolean endOfStream, int payloadSize) throws IOException {
+    protected HeaderFrameBuffers doWriteHeaders(Stream stream, MimeHeaders mimeHeaders, boolean endOfStream,
+            int payloadSize) throws IOException {
 
         if (log.isDebugEnabled()) {
-            if (pushedStreamId == 0) {
-                log.debug(sm.getString("upgradeHandler.writeHeaders", connectionId, stream.getIdAsString(),
-                        Boolean.valueOf(endOfStream)));
-            } else {
-                log.debug(sm.getString("upgradeHandler.writePushHeaders", connectionId, stream.getIdAsString(),
-                        Integer.valueOf(pushedStreamId), Boolean.valueOf(endOfStream)));
-            }
+            log.debug(sm.getString("upgradeHandler.writeHeaders", connectionId, stream.getIdAsString(),
+                    Boolean.valueOf(endOfStream)));
         }
 
         if (!stream.canWrite()) {
@@ -738,31 +732,18 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
 
         HeaderFrameBuffers headerFrameBuffers = getHeaderFrameBuffers(payloadSize);
 
-        byte[] pushedStreamIdBytes = null;
-        if (pushedStreamId > 0) {
-            pushedStreamIdBytes = new byte[4];
-            ByteUtil.set31Bits(pushedStreamIdBytes, 0, pushedStreamId);
-        }
-
         boolean first = true;
         State state = null;
 
         while (state != State.COMPLETE) {
             headerFrameBuffers.startFrame();
-            if (first && pushedStreamIdBytes != null) {
-                headerFrameBuffers.getPayload().put(pushedStreamIdBytes);
-            }
             state = getHpackEncoder().encode(mimeHeaders, headerFrameBuffers.getPayload());
             headerFrameBuffers.getPayload().flip();
             if (state == State.COMPLETE || headerFrameBuffers.getPayload().limit() > 0) {
                 ByteUtil.setThreeBytes(headerFrameBuffers.getHeader(), 0, headerFrameBuffers.getPayload().limit());
                 if (first) {
                     first = false;
-                    if (pushedStreamIdBytes == null) {
-                        headerFrameBuffers.getHeader()[3] = FrameType.HEADERS.getIdByte();
-                    } else {
-                        headerFrameBuffers.getHeader()[3] = FrameType.PUSH_PROMISE.getIdByte();
-                    }
+                    headerFrameBuffers.getHeader()[3] = FrameType.HEADERS.getIdByte();
                     if (endOfStream) {
                         headerFrameBuffers.getHeader()[4] = FLAG_END_OF_STREAM;
                     }
@@ -1255,17 +1236,6 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
     }
 
 
-    private Stream createLocalStream(Request request) {
-        int streamId = nextLocalStreamId.getAndAdd(2);
-
-        Integer key = Integer.valueOf(streamId);
-
-        Stream result = new Stream(key, this, request);
-        streams.put(key, result);
-        return result;
-    }
-
-
     private void close() {
         ConnectionState previous = connectionState.getAndSet(ConnectionState.CLOSED);
         if (previous == ConnectionState.CLOSED) {
@@ -1345,36 +1315,6 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
     }
 
 
-    void push(Request request, Stream associatedStream) throws IOException {
-        if (localSettings.getMaxConcurrentStreams() < activeRemoteStreamCount.incrementAndGet()) {
-            // If there are too many open streams, simply ignore the push
-            // request.
-            setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet());
-            return;
-        }
-
-        Stream pushStream;
-
-        /*
-         * Uses SocketWrapper lock since PUSH_PROMISE frames have to be sent in order. Once the stream has been created
-         * we need to ensure that the PUSH_PROMISE is sent before the next stream is created for a PUSH_PROMISE.
-         */
-        Lock lock = socketWrapper.getLock();
-        lock.lock();
-        try {
-            pushStream = createLocalStream(request);
-            writeHeaders(associatedStream, pushStream.getIdAsInt(), request.getMimeHeaders(), false,
-                    Constants.DEFAULT_HEADERS_FRAME_SIZE);
-        } finally {
-            lock.unlock();
-        }
-
-        pushStream.sentPushPromise();
-
-        processStreamOnContainerThread(pushStream);
-    }
-
-
     @Override
     protected final String getConnectionId() {
         return connectionId;
diff --git a/java/org/apache/coyote/http2/LocalStrings.properties b/java/org/apache/coyote/http2/LocalStrings.properties
index 5872e2c313..0213ca23ef 100644
--- a/java/org/apache/coyote/http2/LocalStrings.properties
+++ b/java/org/apache/coyote/http2/LocalStrings.properties
@@ -169,7 +169,6 @@ upgradeHandler.windowUpdateConnection=Connection [{0}], Sent window update to cl
 upgradeHandler.windowUpdateStream=Connection [{0}], Stream [{1}], Sent window update to client increasing window by [{2}] bytes
 upgradeHandler.writeBody=Connection [{0}], Stream [{1}], Data length [{2}], EndOfStream [{3}]
 upgradeHandler.writeHeaders=Connection [{0}], Stream [{1}], Writing the headers, EndOfStream [{2}]
-upgradeHandler.writePushHeaders=Connection [{0}], Stream [{1}], Pushed stream [{2}], EndOfStream [{3}]
 
 windowAllocationManager.dispatched=Connection [{0}], Stream [{1}], Dispatched
 windowAllocationManager.notified=Connection [{0}], Stream [{1}], Notified
diff --git a/java/org/apache/coyote/http2/LocalStrings_fr.properties b/java/org/apache/coyote/http2/LocalStrings_fr.properties
index e510bbb3f8..16db006759 100644
--- a/java/org/apache/coyote/http2/LocalStrings_fr.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_fr.properties
@@ -169,7 +169,6 @@ upgradeHandler.windowUpdateConnection=Connection [{0}], envoi de la mise à jour
 upgradeHandler.windowUpdateStream=Connection [{0}], Stream [{1}], envoi de la mise à jour de la fenêtre augmentant celle ci de [{2}] octets
 upgradeHandler.writeBody=Connection [{0}], Flux [{1}], Taille des données [{2}]
 upgradeHandler.writeHeaders=Connection [{0}], Stream [{1}]
-upgradeHandler.writePushHeaders=Connection [{0}], Flux [{1}], Flux de push [{2}], EndOfStream [{3}]
 
 windowAllocationManager.dispatched=Connection [{0}], Flux [{1}], Envoyé
 windowAllocationManager.notified=Connection [{0}], Flux [{1}], Notifié
diff --git a/java/org/apache/coyote/http2/LocalStrings_ja.properties b/java/org/apache/coyote/http2/LocalStrings_ja.properties
index c868d036f8..4ea12dff68 100644
--- a/java/org/apache/coyote/http2/LocalStrings_ja.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_ja.properties
@@ -168,7 +168,6 @@ upgradeHandler.windowUpdateConnection=接続[{0}]、ウィンドウの更新を
 upgradeHandler.windowUpdateStream=接続 [{0}]、ストリーム [{1}]、ウィンドウの更新をクライアントに送信し、ウィンドウを [{2}] バイト増やします
 upgradeHandler.writeBody=コネクション [{0}]、ストリーム [{1}]、データ長 [{2}]
 upgradeHandler.writeHeaders=コネクション [{0}], ストリーム [{1}]
-upgradeHandler.writePushHeaders=コネクション [{0}]、ストリーム [{1}]、プッシュされたストリーム [{2}]、EndOfStream [{3}]
 
 windowAllocationManager.dispatched=接続 [{0}]、ストリーム [{1}]、ディスパッチされました
 windowAllocationManager.notified=接続 [{0}]、ストリーム [{1}]、通知されました
diff --git a/java/org/apache/coyote/http2/LocalStrings_ko.properties b/java/org/apache/coyote/http2/LocalStrings_ko.properties
index 5893a35934..a10474fba5 100644
--- a/java/org/apache/coyote/http2/LocalStrings_ko.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_ko.properties
@@ -165,7 +165,6 @@ upgradeHandler.windowUpdateConnection=연결 [{0}], 윈도우 크기를 [{1}] 
 upgradeHandler.windowUpdateStream=연결 [{0}], 스트림 [{1}], 윈도우 크기를 [{2}] 바이트 만큼 늘리며, 클라이언트에게 윈도우 변경 프레임을 전송했습니다.
 upgradeHandler.writeBody=연결 [{0}], 스트림 [{1}], 데이터 길이 [{2}]
 upgradeHandler.writeHeaders=연결 [{0}], 스트림 [{1}]
-upgradeHandler.writePushHeaders=연결 [{0}], 스트림 [{1}], Push된 스트림 [{2}], EndOfStream [{3}]
 
 windowAllocationManager.dispatched=연결 [{0}], 스트림 [{1}]에 디스패치됩니다.
 windowAllocationManager.notified=연결 [{0}], 스트림 [{1}]에 통지됩니다.
diff --git a/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties b/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
index 41f43061ad..622d0c8954 100644
--- a/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
+++ b/java/org/apache/coyote/http2/LocalStrings_zh_CN.properties
@@ -164,7 +164,6 @@ upgradeHandler.windowUpdateConnection=连接[{0}],向客户端发送了窗口更
 upgradeHandler.windowUpdateStream=连接[{0}],流[{1}]向客户端发送了窗口更新,将窗口增加[{2}]字节
 upgradeHandler.writeBody=连接 [{0}],数据流[{1}], 数据长度[{2}]
 upgradeHandler.writeHeaders=连接[{0}],流[{1}],正在写入头信息,EndOfStream[{2}]
-upgradeHandler.writePushHeaders=连接[{0}]、流[{1}]、推送流[{2}]、EndOfStream[{3}]
 
 windowAllocationManager.dispatched=连接[{0}],流[{1}],已调度
 windowAllocationManager.notified=连接[{0}],流[{1}],已通知
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 7fa900aced..e2300d5129 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -118,7 +118,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
             this.inputBuffer = new StandardStreamInputBuffer();
             this.coyoteRequest.setInputBuffer(inputBuffer);
         } else {
-            // HTTP/2 Push or HTTP/1.1 upgrade
+            // HTTP/1.1 upgrade
             this.coyoteRequest = coyoteRequest;
             this.inputBuffer =
                     new SavedRequestStreamInputBuffer((SavedRequestInputFilter) coyoteRequest.getInputBuffer());
@@ -162,8 +162,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
         if (hostValueMB == null) {
             throw new IllegalArgumentException();
         }
-        // This processing expects bytes. Server push will have used a String
-        // so trigger a conversion if required.
+        // This processing expects bytes. Trigger a conversion if required.
         hostValueMB.toBytes();
         ByteChunk valueBC = hostValueMB.getByteChunk();
         byte[] valueB = valueBC.getBytes();
@@ -546,8 +545,7 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
 
     final void writeHeaders() throws IOException {
         boolean endOfStream = streamOutputBuffer.hasNoBody() && coyoteResponse.getTrailerFields() == null;
-        handler.writeHeaders(this, 0, coyoteResponse.getMimeHeaders(), endOfStream,
-                Constants.DEFAULT_HEADERS_FRAME_SIZE);
+        handler.writeHeaders(this, coyoteResponse.getMimeHeaders(), endOfStream, Constants.DEFAULT_HEADERS_FRAME_SIZE);
     }
 
 
@@ -581,12 +579,12 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
             mb.setString(headerEntry.getValue());
         }
 
-        handler.writeHeaders(this, 0, mimeHeaders, true, Constants.DEFAULT_HEADERS_FRAME_SIZE);
+        handler.writeHeaders(this, mimeHeaders, true, Constants.DEFAULT_HEADERS_FRAME_SIZE);
     }
 
 
     final void writeAck() throws IOException {
-        handler.writeHeaders(this, 0, ACK_HEADERS, false, Constants.DEFAULT_HEADERS_ACK_FRAME_SIZE);
+        handler.writeHeaders(this, ACK_HEADERS, false, Constants.DEFAULT_HEADERS_ACK_FRAME_SIZE);
     }
 
 
@@ -609,9 +607,8 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
     @Override
     final ByteBuffer getInputByteBuffer() {
         if (inputBuffer == null) {
-            // This must either be a push or an HTTP upgrade. Either way there
-            // should not be a request body so return a zero length ByteBuffer
-            // to trigger a flow control error.
+            // This must either be an HTTP upgrade. There should not be a request body so return a zero length
+            //ByteBuffer to trigger a flow control error.
             return ZERO_LENGTH_BYTEBUFFER;
         }
         return inputBuffer.getInBuffer();
@@ -708,11 +705,6 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
     }
 
 
-    final void sentPushPromise() {
-        state.sentPushPromise();
-    }
-
-
     final boolean isActive() {
         return state.isActive();
     }
@@ -789,40 +781,6 @@ class Stream extends AbstractNonZeroStream implements HeaderEmitter {
     }
 
 
-    final boolean isPushSupported() {
-        return handler.getRemoteSettings().getEnablePush();
-    }
-
-
-    final void push(Request request) throws IOException {
-        // Can only push when supported and from a peer initiated stream
-        if (!isPushSupported() || getIdAsInt() % 2 == 0) {
-            return;
-        }
-        // Set the special HTTP/2 headers
-        request.getMimeHeaders().addValue(":method").duplicate(request.method());
-        request.getMimeHeaders().addValue(":scheme").duplicate(request.scheme());
-        StringBuilder path = new StringBuilder(request.requestURI().toString());
-        if (!request.queryString().isNull()) {
-            path.append('?');
-            path.append(request.queryString().toString());
-        }
-        request.getMimeHeaders().addValue(":path").setString(path.toString());
-
-        // Authority needs to include the port only if a non-standard port is
-        // being used.
-        if (!(request.scheme().equals("http") && request.getServerPort() == 80) &&
-                !(request.scheme().equals("https") && request.getServerPort() == 443)) {
-            request.getMimeHeaders().addValue(":authority")
-                    .setString(request.serverName().getString() + ":" + request.getServerPort());
-        } else {
-            request.getMimeHeaders().addValue(":authority").duplicate(request.serverName());
-        }
-
-        handler.push(request, this);
-    }
-
-
     boolean isTrailerFieldsReady() {
         // Once EndOfStream has been received, canRead will be false
         return !state.canRead();
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java
index d041abe389..be119cdd0d 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -361,23 +361,6 @@ class StreamProcessor extends AbstractProcessor {
     }
 
 
-    @Override
-    protected final boolean isPushSupported() {
-        return stream.isPushSupported();
-    }
-
-
-    @Override
-    protected final void doPush(Request pushTarget) {
-        try {
-            stream.push(pushTarget);
-        } catch (IOException ioe) {
-            setErrorState(ErrorState.CLOSE_CONNECTION_NOW, ioe);
-            response.setErrorException(ioe);
-        }
-    }
-
-
     @Override
     protected boolean isTrailerFieldsReady() {
         return stream.isTrailerFieldsReady();
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java b/java/org/apache/coyote/http2/StreamStateMachine.java
index bafb24193a..53e2cc53e3 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -49,11 +49,6 @@ class StreamStateMachine {
     }
 
 
-    final synchronized void sentPushPromise() {
-        stateChange(State.IDLE, State.RESERVED_LOCAL);
-    }
-
-
     final synchronized void sentHeaders() {
         // No change if currently OPEN
         stateChange(State.RESERVED_LOCAL, State.HALF_CLOSED_REMOTE);
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java
index 14f5aa11d7..2a432363cb 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1267,14 +1267,6 @@ public abstract class Http2TestBase extends TomcatBaseTest {
         }
 
 
-        public void pushPromise(int streamId, int pushedStreamId) {
-            trace.append(streamId);
-            trace.append("-PushPromise-");
-            trace.append(pushedStreamId);
-            trace.append("\n");
-        }
-
-
         public void clearTrace() {
             trace = new StringBuffer();
             bytesRead = 0;
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
index f826914013..cba4b88958 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
@@ -71,8 +71,6 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
     }
 
 
-    // Need to test sending push promise when push promise support is disabled
-
     @Test
     public void testSettingsFrameInvalidPushSetting() throws Exception {
         // HTTP2 upgrade
diff --git a/test/org/apache/coyote/http2/TesterHttp2Parser.java b/test/org/apache/coyote/http2/TesterHttp2Parser.java
index 3b4f10af39..73d0a7557f 100644
--- a/test/org/apache/coyote/http2/TesterHttp2Parser.java
+++ b/test/org/apache/coyote/http2/TesterHttp2Parser.java
@@ -17,7 +17,6 @@
 package org.apache.coyote.http2;
 
 import java.io.IOException;
-import java.nio.ByteBuffer;
 
 import org.apache.coyote.http2.Http2TestBase.TestOutput;
 
@@ -26,11 +25,8 @@ import org.apache.coyote.http2.Http2TestBase.TestOutput;
  */
 public class TesterHttp2Parser extends Http2Parser {
 
-    private final TestOutput output;
-
     TesterHttp2Parser(String connectionId, Input input, TestOutput output) {
         super(connectionId, input, output);
-        this.output = output;
     }
 
 
@@ -43,50 +39,4 @@ public class TesterHttp2Parser extends Http2Parser {
     public boolean readFrame() throws Http2Exception, IOException {
         return super.readFrame();
     }
-
-    @Override
-    protected void readPushPromiseFrame(int streamId, int flags, int payloadSize, ByteBuffer buffer)
-            throws Http2Exception, IOException {
-
-        // Parse flags used in this method
-        boolean hasPadding = Flags.hasPadding(flags);
-        boolean headersEndStream = Flags.isEndOfStream(flags);
-
-        // Padding size
-        int paddingSize = 0;
-        if (hasPadding) {
-            byte[] bPadSize = new byte[1];
-            if (buffer == null) {
-                input.fill(true, bPadSize);
-            } else {
-                buffer.get(bPadSize);
-            }
-            paddingSize = ByteUtil.getOneByte(bPadSize, 0);
-        }
-
-        // Pushed stream ID
-        byte[] bPushedStreamId = new byte[4];
-        if (buffer == null) {
-            input.fill(true, bPushedStreamId);
-        } else {
-            buffer.get(bPushedStreamId);
-        }
-        int pushedStreamId = ByteUtil.get31Bits(bPushedStreamId, 0);
-
-        output.pushPromise(streamId, pushedStreamId);
-
-        int headerSize = payloadSize - 4 - paddingSize;
-        if (hasPadding) {
-            headerSize--;
-        }
-
-        HpackDecoder hpackDecoder = output.getHpackDecoder();
-        hpackDecoder.setHeaderEmitter(output.headersStart(pushedStreamId, headersEndStream));
-
-        readHeaderPayload(pushedStreamId, headerSize, buffer);
-
-        if (hasPadding) {
-            swallowPayload(streamId, FrameType.PUSH_PROMISE.getId(), paddingSize, true, buffer);
-        }
-    }
 }


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


[tomcat] 01/03: Deprecate PushBuilder as per latest Servlet 6.1

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3c0791abb95342a9e5fcf90eb4a18a9c6188c269
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Oct 2 11:43:01 2023 +0100

    Deprecate PushBuilder as per latest Servlet 6.1
---
 java/jakarta/servlet/http/HttpServletRequest.java        | 9 ++++++---
 java/jakarta/servlet/http/HttpServletRequestWrapper.java | 3 +++
 java/jakarta/servlet/http/PushBuilder.java               | 3 +++
 webapps/docs/changelog.xml                               | 5 +++++
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/java/jakarta/servlet/http/HttpServletRequest.java b/java/jakarta/servlet/http/HttpServletRequest.java
index 7bb78cb999..8e36a97ccd 100644
--- a/java/jakarta/servlet/http/HttpServletRequest.java
+++ b/java/jakarta/servlet/http/HttpServletRequest.java
@@ -223,12 +223,15 @@ public interface HttpServletRequest extends ServletRequest {
      * instance obtained.
      *
      * @return A builder that can be used to generate push requests based on this request or {@code null} if push is not
-     *             supported. Note that even if a PushBuilder instance is returned, by the time that
-     *             {@link PushBuilder#push()} is called, it may no longer be valid to push a request and the push
-     *             request will be ignored.
+     *             supported. Some implementations may opt not to support server push and will therefore always return
+     *             {@code null}. If a PushBuilder instance is returned, by the time that {@link PushBuilder#push()} is
+     *             called, it may no longer be valid to push a request and the push request will be ignored.
      *
      * @since Servlet 4.0
+     *
+     * @deprecated In favor of 103 early hints
      */
+    @Deprecated
     default PushBuilder newPushBuilder() {
         return null;
     }
diff --git a/java/jakarta/servlet/http/HttpServletRequestWrapper.java b/java/jakarta/servlet/http/HttpServletRequestWrapper.java
index 766488be9d..ac56f2cee8 100644
--- a/java/jakarta/servlet/http/HttpServletRequestWrapper.java
+++ b/java/jakarta/servlet/http/HttpServletRequestWrapper.java
@@ -349,7 +349,10 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements
      * request object.
      *
      * @since Servlet 4.0
+     *
+     * @deprecated In favor of 103 early hints
      */
+    @Deprecated
     @Override
     public PushBuilder newPushBuilder() {
         return this._getHttpServletRequest().newPushBuilder();
diff --git a/java/jakarta/servlet/http/PushBuilder.java b/java/jakarta/servlet/http/PushBuilder.java
index 9a1092011d..46c6ed72bc 100644
--- a/java/jakarta/servlet/http/PushBuilder.java
+++ b/java/jakarta/servlet/http/PushBuilder.java
@@ -32,7 +32,10 @@ import java.util.Set;
  * </ul>
  *
  * @since Servlet 4.0
+ *
+ * @deprecated In favor of 103 early hints
  */
+@Deprecated
 public interface PushBuilder {
 
     /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8dc474f05b..0addab5e1f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,11 @@
         Improve statistics collection for upgraded connections under load.
         (remm)
       </fix>
+      <update>
+        <code>PushBuilder</code> has been deprecated in line with the changes
+        for the Servlet 6.1 specification. It will be replaced in a future
+        Tomcat 11 milestone with support for 103 early hints. (markt)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Jasper">


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