Skip to content
Snippets Groups Projects
Verified Commit bf7a7ae4 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

ENH: Allow plain HTTP

parent 05c7af28
No related branches found
No related tags found
No related merge requests found
Pipeline #56432 failed
......@@ -545,11 +545,23 @@ public class CaosDBServer extends Application {
// redirector http to https
if (port_http != 0) {
logger.info("Redirecting to " + port_redirect_https);
if (isHttpToHttpsRedirect()) {
logger.info("Redirecting HTTP " + port_http + " to HTTPS " + port_redirect_https);
component
.getServers()
.add(Protocol.HTTP, server_bind_address, port_http)
.setNext(new HttpToHttpsRedirector(port_redirect_https));
} else {
final Server httpServer =
new Server(
(Context) null,
Arrays.asList(Protocol.HTTP),
server_bind_address,
port_http,
(Restlet) null,
"org.restlet.ext.jetty.HttpServerHelper");
component.getServers().add(httpServer);
}
}
// set initial and maximal connections
......@@ -601,6 +613,16 @@ public class CaosDBServer extends Application {
}
}
private static boolean isHttpToHttpsRedirect() {
try {
return !getServerProperty(ServerProperties.KEY_REDIRECT_HTTP_TO_HTTPS_PORT)
.equalsIgnoreCase("false");
} catch (NullPointerException e) {
return true;
}
}
/**
* Specify the dispatching restlet that maps URIs to their associated resources for processing.
*
......@@ -997,7 +1019,7 @@ class CaosDBComponent extends Component {
request.getAttributes().put("SRID", UUID.randomUUID().toString());
response.setServerInfo(CaosDBServer.getServerInfo());
super.handle(request, response);
response.getHeaders().set("Access-Control-Allow-Origin", "*", true);
response.setAccessControlAllowOrigin("*");
log(request, response, t1);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment