486511 - Server.getURI() returns wrong scheme on SSL/HTTPS
This commit is contained in:
parent
734d18fb93
commit
e3dd0cb83b
|
@ -654,7 +654,6 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
/**
|
/**
|
||||||
* @return The URI of the first {@link NetworkConnector} and first {@link ContextHandler}, or null
|
* @return The URI of the first {@link NetworkConnector} and first {@link ContextHandler}, or null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("resource")
|
|
||||||
public URI getURI()
|
public URI getURI()
|
||||||
{
|
{
|
||||||
NetworkConnector connector=null;
|
NetworkConnector connector=null;
|
||||||
|
@ -674,7 +673,10 @@ public class Server extends HandlerWrapper implements Attributes
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String scheme=connector.getDefaultConnectionFactory().getProtocol().startsWith("SSL-")?"https":"http";
|
String protocol = connector.getDefaultConnectionFactory().getProtocol();
|
||||||
|
String scheme="http";
|
||||||
|
if (protocol.startsWith("SSL-") || protocol.equals("SSL"))
|
||||||
|
scheme = "https";
|
||||||
|
|
||||||
String host=connector.getHost();
|
String host=connector.getHost();
|
||||||
if (context!=null && context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
if (context!=null && context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||||
|
|
|
@ -18,12 +18,16 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server.ssl;
|
package org.eclipse.jetty.server.ssl;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.URI;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -92,6 +96,15 @@ public class SSLSelectChannelConnectorLoadTest
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetURI()
|
||||||
|
{
|
||||||
|
URI uri = server.getURI();
|
||||||
|
assertThat("Server.uri.scheme", uri.getScheme(), is("https"));
|
||||||
|
assertThat("Server.uri.port", uri.getPort(), is(connector.getLocalPort()));
|
||||||
|
assertThat("Server.uri.path", uri.getPath(), is("/"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLongLivedConnections() throws Exception
|
public void testLongLivedConnections() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue