mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 23:15:49 +01:00
Refactorization of the https command line option
Renaming the flag variable and the Connector class.
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
<zip destfile="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
<zip destfile="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
||||||
basedir="${target.dir}/scala-${scala.version}/classes"
|
basedir="${target.dir}/scala-${scala.version}/classes"
|
||||||
update = "true"
|
update = "true"
|
||||||
includes="JettyLauncher.class,SslConnector.class"/>
|
includes="JettyLauncher.class,CustomConnector.class"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="rename" depends="embed">
|
<target name="rename" depends="embed">
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class JettyLauncher {
|
|||||||
String host = null;
|
String host = null;
|
||||||
int port = 8080;
|
int port = 8080;
|
||||||
String contextPath = "/";
|
String contextPath = "/";
|
||||||
boolean httpsScheme = false;
|
boolean forceHttps = false;
|
||||||
|
|
||||||
for(String arg: args) {
|
for(String arg: args) {
|
||||||
if(arg.startsWith("--") && arg.contains("=")) {
|
if(arg.startsWith("--") && arg.contains("=")) {
|
||||||
@@ -26,7 +26,7 @@ public class JettyLauncher {
|
|||||||
} else if(dim[0].equals("--prefix")) {
|
} else if(dim[0].equals("--prefix")) {
|
||||||
contextPath = dim[1];
|
contextPath = dim[1];
|
||||||
} else if(dim[0].equals("--https") && (dim[1].equals("1") || dim[1].equals("true"))) {
|
} else if(dim[0].equals("--https") && (dim[1].equals("1") || dim[1].equals("true"))) {
|
||||||
httpsScheme = true;
|
forceHttps = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public class JettyLauncher {
|
|||||||
|
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
|
|
||||||
SslConnector connector = new SslConnector(httpsScheme);
|
CustomConnector connector = new CustomConnector(forceHttps);
|
||||||
if(host != null) {
|
if(host != null) {
|
||||||
connector.setHost(host);
|
connector.setHost(host);
|
||||||
}
|
}
|
||||||
@@ -58,16 +58,16 @@ public class JettyLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SslConnector extends SelectChannelConnector {
|
class CustomConnector extends SelectChannelConnector {
|
||||||
boolean myHttpsScheme;
|
boolean mForceHttps;
|
||||||
|
|
||||||
public SslConnector(boolean httpsScheme) {
|
public CustomConnector(boolean forceHttps) {
|
||||||
myHttpsScheme = httpsScheme;
|
mForceHttps = forceHttps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(final EndPoint endpoint, final Request request) throws IOException {
|
public void customize(final EndPoint endpoint, final Request request) throws IOException {
|
||||||
if (myHttpsScheme) {
|
if (mForceHttps) {
|
||||||
request.setScheme("https");
|
request.setScheme("https");
|
||||||
super.customize(endpoint, request);
|
super.customize(endpoint, request);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user