mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-04-01 18:00:12 +02:00
use configured server port in cgis for mod_proxy
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.util;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -75,6 +79,37 @@ public class HttpUtil
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param configuration
|
||||
* @param request
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getServerPort(ScmConfiguration configuration,
|
||||
HttpServletRequest request)
|
||||
{
|
||||
int port = 0;
|
||||
|
||||
if (configuration.isEnableSSL())
|
||||
{
|
||||
port = configuration.getSslPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
port = configuration.getPort();
|
||||
}
|
||||
|
||||
if (port <= 0)
|
||||
{
|
||||
port = request.getLocalPort();
|
||||
}
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
|
||||
package sonia.scm.web.cgi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
@@ -55,6 +60,19 @@ public abstract class AbstractCGIServlet extends HttpServlet
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -8638099037069714140L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param configuration
|
||||
*/
|
||||
public AbstractCGIServlet(ScmConfiguration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -157,7 +175,7 @@ public abstract class AbstractCGIServlet extends HttpServlet
|
||||
{
|
||||
cgiRunner.exec(createRequestEnvironment(req, baseEnvironment),
|
||||
getCmdPrefix(), getCommand(req), req.getPathInfo(), req,
|
||||
resp);
|
||||
resp, HttpUtil.getServerPort(configuration, req));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -191,4 +209,7 @@ public abstract class AbstractCGIServlet extends HttpServlet
|
||||
|
||||
/** Field description */
|
||||
private CGIRunner cgiRunner;
|
||||
|
||||
/** Field description */
|
||||
private ScmConfiguration configuration;
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ public class CGIRunner
|
||||
* @throws IOException
|
||||
*/
|
||||
public void exec(EnvList environment, File command, String pathInfo,
|
||||
HttpServletRequest req, HttpServletResponse res)
|
||||
HttpServletRequest req, HttpServletResponse res, int serverPort)
|
||||
throws IOException
|
||||
{
|
||||
exec(environment, defaultCmdPrefix, command, pathInfo, req, res);
|
||||
exec(environment, defaultCmdPrefix, command, pathInfo, req, res, serverPort);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ public class CGIRunner
|
||||
*/
|
||||
public void exec(EnvList environment, String cmdPrefix, File command,
|
||||
String pathInfo, HttpServletRequest req,
|
||||
HttpServletResponse res)
|
||||
HttpServletResponse res, int serverPort)
|
||||
throws IOException
|
||||
{
|
||||
String path = command.getAbsolutePath();
|
||||
@@ -169,7 +169,7 @@ public class CGIRunner
|
||||
environment.set("SCRIPT_NAME", scriptName);
|
||||
environment.set("SCRIPT_FILENAME", scriptPath);
|
||||
environment.set("SERVER_NAME", req.getServerName());
|
||||
environment.set("SERVER_PORT", Integer.toString(req.getServerPort()));
|
||||
environment.set("SERVER_PORT", Integer.toString(serverPort));
|
||||
environment.set("SERVER_PROTOCOL", req.getProtocol());
|
||||
environment.set("SERVER_SOFTWARE", context.getServerInfo());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user