diff --git a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java index 12a00e9..2a0f347 100644 --- a/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java +++ b/appengine-managed-runtime/src/main/java/com/google/apphosting/vmruntime/VmApiProxyEnvironment.java @@ -454,7 +454,6 @@ public static VmApiProxyEnvironment createFromHeaders( private final String server; private volatile String ticket; // request ticket is only valid until response is committed. private volatile String globalTicket; // global ticket is always valid - private final int serverPort; private final String partition; private final String appId; private final String module; @@ -541,11 +540,6 @@ private VmApiProxyEnvironment( this.server = server; this.partition = partition; - String port = - System.getenv(GAE_SERVER_PORT) == null - ? System.getProperty("GAE_SERVER_PORT", "80") - : System.getenv(GAE_SERVER_PORT); - this.serverPort = Integer.decode(port); this.appId = partition + "~" + appId; this.module = module == null ? "default" : module; this.majorVersion = majorVersion == null ? "" : majorVersion; @@ -618,10 +612,6 @@ public String getPartition() { return partition; } - public int getServerPort() { - return serverPort; - } - @Override public String getAppId() { return appId; diff --git a/jetty9-compat-base/pom.xml b/jetty9-compat-base/pom.xml index 73f467c..e1df4b3 100644 --- a/jetty9-compat-base/pom.xml +++ b/jetty9-compat-base/pom.xml @@ -41,6 +41,12 @@ ${project.version} jar + + com.google.appengine + jetty9-base + ${project.version} + jar + org.eclipse.jetty jetty-security diff --git a/jetty9-compat-base/src/main/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContext.java b/jetty9-compat-base/src/main/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContext.java index eb0795e..912bdc1 100644 --- a/jetty9-compat-base/src/main/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContext.java +++ b/jetty9-compat-base/src/main/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContext.java @@ -248,27 +248,6 @@ private static List createSessionStores(AppEngineWebXml appEngineW return Arrays.asList(datastoreSessionStore, new MemcacheSessionStore()); } - /** - * Checks if the request was made over HTTPS. If so it modifies the request so that {@code - * HttpServletRequest#isSecure()} returns true, {@code HttpServletRequest#getScheme()} returns - * "https", and {@code HttpServletRequest#getServerPort()} returns 443. Otherwise it sets the - * scheme to "http" and port to 80. - * - * @param request The request to modify. - */ - private void setSchemeAndPort(Request request) { - String https = request.getHeader(VmApiProxyEnvironment.HTTPS_HEADER); - if ("on".equals(https)) { - request.setSecure(true); - request.setScheme(HttpScheme.HTTPS.toString()); - request.setAuthority(request.getServerName(), 443); - } else { - request.setSecure(false); - request.setScheme(HttpScheme.HTTP.toString()); - request.setAuthority(request.getServerName(), defaultEnvironment.getServerPort()); - } - } - /** * Creates a new VmRuntimeWebAppContext. */ @@ -450,9 +429,6 @@ public void requestInitialized(ServletRequestEvent sre) { // Check for SkipAdminCheck and set attributes accordingly. VmRuntimeUtils.handleSkipAdminCheck(requestContext); - - // Change scheme to HTTPS based on headers set by the appserver. - setSchemeAndPort(baseRequest); } @Override diff --git a/jetty9-compat-base/src/main/jetty-base/etc/gae.xml b/jetty9-compat-base/src/main/jetty-base/etc/gae.xml index b837375..7e23932 100644 --- a/jetty9-compat-base/src/main/jetty-base/etc/gae.xml +++ b/jetty9-compat-base/src/main/jetty-base/etc/gae.xml @@ -30,10 +30,30 @@ - + + + + + + + + + + + 80 + + + + + + + + + + diff --git a/jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java b/jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java index 375de62..3f8541c 100644 --- a/jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java +++ b/jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java @@ -19,6 +19,7 @@ import static com.google.apphosting.vmruntime.VmRuntimeFileLogHandler.JAVA_UTIL_LOGGING_CONFIG_PROPERTY; import static com.google.apphosting.vmruntime.jetty9.VmRuntimeTestBase.JETTY_HOME_PATTERN; +import com.google.apphosting.jetty9.GoogleRequestCustomizer; import com.google.apphosting.vmruntime.VmRuntimeFileLogHandler; import org.eclipse.jetty.apache.jsp.JettyJasperInitializer; @@ -166,6 +167,9 @@ public void doStart() throws Exception { httpConfig.setSendServerVersion(true); httpConfig.setSendDateHeader(false); httpConfig.setDelayDispatchUntilContent(false); + GoogleRequestCustomizer requestCustomizer = + new GoogleRequestCustomizer(port, 443); + httpConfig.addCustomizer(requestCustomizer); // Setup Server as done by gae.xml server.addBean(bufferpool); @@ -260,7 +264,6 @@ protected void setSystemProperties(File logs) throws IOException { System.setProperty("jetty.appenginehost", "localhost"); System.setProperty("jetty.appengine.forwarded", "true"); System.setProperty("jetty.home", JETTY_HOME_PATTERN); - System.setProperty("GAE_SERVER_PORT", "" + port); } public static int findAvailablePort() {