Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Allow proxy configuration to be passed as environment variables #123

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -37,8 +37,25 @@ public class XMLServerLauncher {
* and output streams.
*/
public static void main(String[] args) {

final String HTTP_PROXY_HOST = System.getenv("HTTP_PROXY_HOST");
final String HTTP_PROXY_PORT = System.getenv("HTTP_PROXY_PORT");
final String HTTP_PROXY_USERNAME = System.getenv("HTTP_PROXY_USERNAME");
final String HTTP_PROXY_PASSWORD = System.getenv("HTTP_PROXY_PASSWORD");

if (HTTP_PROXY_HOST != null && HTTP_PROXY_PORT != null) {
System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
System.setProperty("http.proxyPort", HTTP_PROXY_PORT);
}

if (HTTP_PROXY_USERNAME != null && HTTP_PROXY_PASSWORD != null) {
System.setProperty("http.proxyUser", HTTP_PROXY_USERNAME);
System.setProperty("http.proxyPassword", HTTP_PROXY_PASSWORD);
}

final String username = System.getProperty("http.proxyUser");
final String password = System.getProperty("http.proxyPassword");

if (username != null && password != null) {
Authenticator.setDefault(new Authenticator() {

@@ -60,7 +77,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
/**
* Launches {@link XMLLanguageServer} and makes it accessible through the JSON
* RPC protocol defined by the LSP.
*
*
* @param launcherFuture The future returned by
* {@link org.eclipse.lsp4j.jsonrpc.Launcher#startListening()}.
* (I'm not 100% sure how it meant to be used though, as
@@ -84,7 +101,7 @@ public static Future<?> launch(InputStream in, OutputStream out) {
* Threads are started with the given executor service. The wrapper function is
* applied to the incoming and outgoing message streams so additional message
* handling such as validation and tracing can be included.
*
*
* @param server - the server that receives method calls from the
* remote client
* @param in - input stream to listen for incoming messages