From 9158115a82dd786ded740d5d0511628a6b29edf8 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 12 Mar 2012 15:31:23 +0100 Subject: [PATCH] Improved SPDY connector to take into account confidential and integral settings. --- .../spdy/http/HTTPSPDYServerConnector.java | 35 +++++++++++++++++++ .../jetty/spdy/SPDYServerConnector.java | 9 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java index 8f64049f1aa..b8359cde9c0 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/HTTPSPDYServerConnector.java @@ -16,6 +16,11 @@ package org.eclipse.jetty.spdy.http; +import java.io.IOException; + +import org.eclipse.jetty.http.HttpSchemes; +import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.server.Request; import org.eclipse.jetty.spdy.AsyncConnectionFactory; import org.eclipse.jetty.spdy.SPDYServerConnector; import org.eclipse.jetty.spdy.api.SPDY; @@ -52,4 +57,34 @@ public class HTTPSPDYServerConnector extends SPDYServerConnector { return defaultConnectionFactory; } + + @Override + public void customize(EndPoint endPoint, Request request) throws IOException + { + super.customize(endPoint, request); + if (getSslContextFactory() != null) + request.setScheme(HttpSchemes.HTTPS); + } + + @Override + public boolean isConfidential(Request request) + { + if (getSslContextFactory() != null) + { + int confidentialPort = getConfidentialPort(); + return confidentialPort == 0 || confidentialPort == request.getServerPort(); + } + return super.isConfidential(request); + } + + @Override + public boolean isIntegral(Request request) + { + if (getSslContextFactory() != null) + { + int integralPort = getIntegralPort(); + return integralPort == 0 || integralPort == request.getServerPort(); + } + return super.isIntegral(request); + } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java index be25c0fa4a4..6e5f913d69c 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java @@ -76,7 +76,7 @@ public class SPDYServerConnector extends SelectChannelConnector return bufferPool; } - protected Executor getExecutor() + public Executor getExecutor() { final ThreadPool threadPool = getThreadPool(); if (threadPool instanceof Executor) @@ -91,11 +91,16 @@ public class SPDYServerConnector extends SelectChannelConnector }; } - protected ScheduledExecutorService getScheduler() + public ScheduledExecutorService getScheduler() { return scheduler; } + public SslContextFactory getSslContextFactory() + { + return sslContextFactory; + } + @Override protected void doStart() throws Exception {