Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-gerhardt committed Nov 8, 2017
1 parent bef5050 commit a2aa4d5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/net/sf/j2ep/ProxyFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ public void doFilter(ServletRequest request, ServletResponse response,
filterChain.doFilter(request, response);
} else {
String uri = server.getRule().process(getURI(httpRequest));
String url = request.getScheme() + "://" + server.getDomainName() + server.getPath() + uri;
String scheme = server.getScheme();
if (scheme == null) {
scheme = request.getScheme();
}
String url = scheme + "://" + server.getDomainName() + server.getPath() + uri;
log.debug("Connecting to " + url);

ResponseHandler responseHandler = null;
Expand Down
6 changes: 6 additions & 0 deletions src/net/sf/j2ep/model/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public interface Server {
*/
void setConnectionExceptionRecieved(Exception e);

/**
* Returns the scheme (ie. protocol) for this server or null if the original scheme from the request should be used.
* @return The scheme ("http" or "https") or null for any scheme
*/
String getScheme();

/**
* Returns the host name and port for this server.
* @return Host name and port
Expand Down
21 changes: 21 additions & 0 deletions src/net/sf/j2ep/servers/BaseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class BaseServer extends ServerContainerBase implements Server {
*/
private boolean isRewriting;

/**
* The scheme for this server
*/
private String scheme;

/**
* The host and port for this server
*/
Expand Down Expand Up @@ -84,6 +89,13 @@ public HttpServletResponse postExecute(HttpServletResponse response) {
return response;
}

/**
* @see net.sf.j2ep.model.Server#getScheme()
*/
public String getScheme() {
return scheme;
}

/**
* @see net.sf.j2ep.model.Server#getDomainName()
*/
Expand Down Expand Up @@ -122,6 +134,15 @@ public void setIsRewriting(String rewrite) {
}
}

/**
* Sets the scheme.
*
* @param scheme The scheme
*/
public void setScheme(String scheme) {
this.scheme = scheme;
}

/**
* Sets the host and port we are mapping to.
*
Expand Down
7 changes: 7 additions & 0 deletions src/net/sf/j2ep/servers/ClusterContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ public void setConnectionExceptionRecieved(Exception e) {
ClusterContainer.this.statusChecker.interrupt();
}

/**
* @see net.sf.j2ep.model.Server#getScheme()
*/
public String getScheme() {
return null;
}

/**
* @see net.sf.j2ep.model.Server#getDomainName()
*/
Expand Down

0 comments on commit a2aa4d5

Please sign in to comment.