Fixes #1980 - PushCacheFilter does not push TLS offloaded HTTP/2 requests.

Changed HttpChannel to call Request.setSecure() with the scheme of the
request URI.

Changed PushCacheFilter to rely on the referrer URI scheme, and only if
that is missing then using Request.isSecure().

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2017-11-16 23:32:11 +01:00
parent 81ec56b7c3
commit fab4b95925
2 changed files with 11 additions and 1 deletions

View File

@ -40,6 +40,7 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData;
@ -634,6 +635,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
request.setTrailerSupplier(_trailerSupplier);
_request.setMetaData(request);
_request.setSecure(HttpScheme.HTTPS.is(request.getURI().getScheme()));
notifyRequestBegin(_request);
if (LOG.isDebugEnabled())

View File

@ -44,6 +44,7 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.PushBuilder;
@ -175,7 +176,13 @@ public class PushCacheFilter implements Filter
String host = referrerURI.getHost();
int port = referrerURI.getPort();
if (port <= 0)
port = request.isSecure() ? 443 : 80;
{
String scheme = referrerURI.getScheme();
if (scheme != null)
port = HttpScheme.HTTPS.is(scheme) ? 443 : 80;
else
port = request.isSecure() ? 443 : 80;
}
boolean referredFromHere = _hosts.size() > 0 ? _hosts.contains(host) : host.equals(request.getServerName());
referredFromHere &= _ports.size() > 0 ? _ports.contains(port) : port == request.getServerPort();