Skip to content

Commit

Permalink
Also use VS Code proxy config for HTTPS on language server
Browse files Browse the repository at this point in the history
One part of #735

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Jul 14, 2022
1 parent c138e50 commit 0f80194
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion docs/Preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

Can be accessed through `xml.server.vmargs`.

Setting up proxy:
eg. Setting up proxy:

A proxy can be defined in the following way if there is a system proxy:

Expand All @@ -34,6 +34,9 @@
-Dhttp.proxyPassword= <password> -Dhttps.proxyHost=<proxy_host> -Dhttps.proxyPort=<proxy_port>
```

**Please note:** If you've configured the proxy as described in [Proxy.md](Proxy.md), there is no need to do this,
as this will be handled for you by vscode-xml.

## Server Binary Mode

By default, if Java is not installed, a binary version of the LemMinX language server will be downloaded and run.
Expand Down
10 changes: 6 additions & 4 deletions docs/Proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ This page explains how to get vscode-xml to work through a proxy.

## Prerequisites

If you want to use the binary language server,
then you will need to make sure that your proxy allows connections to jboss.org
since the binary language server is downloaded from that website.
You will also need to make sure that you can access any online XML schemas that you want to work with through the proxy.
You need to make sure that you can access any online XML schemas that you want to work with through the proxy.
Also, if are using open-vsx.org instead if Visual Studio Marketplace for extensions,
and you want to use the binary language server,
then you will need to make sure that your proxy allows connections to GitHub,
since the binary language server is downloaded from GitHub when using open-vsx.org [for the time being](https://github.com/redhat-developer/vscode-xml/issues/739).

## Setting up the proxy in VS Code

Expand All @@ -19,6 +20,7 @@ The tested way to get vscode-xml to use your proxy is to set the following setti
* `http.proxy`:
The address at which the proxy can be accessed.
As an example, use `"http://localhost:3128"` for a proxy running on your machine on port 3128.
vscode-xml (as well as VS Code) assumes that the same proxy address is used for the HTTP and HTTPS requests.
* `http.proxyAuthorization`:
The authorization header to use for the proxy requests.
This is only needed when the proxy requires authorization.
Expand Down
6 changes: 4 additions & 2 deletions src/settings/proxySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ export function getProxySettings(): ProxySettings {
export function getProxySettingsAsJVMArgs(proxySettings: ProxySettings): string {
// Java doesn't recognize localhost in the proxy settings
const adaptedHostName = 'localhost'.startsWith(proxySettings.host) ? '127.0.0.1' : proxySettings.host;
let proxyJVMArgs: string = ` -Dhttp.proxyHost=${adaptedHostName} -Dhttp.proxyPort=${proxySettings.port} `;
let proxyJVMArgs: string = ` -Dhttp.proxyHost=${adaptedHostName} -Dhttp.proxyPort=${proxySettings.port}`
+ ` -Dhttps.proxyHost=${adaptedHostName} -Dhttps.proxyPort=${proxySettings.port} `;
if (proxySettings.auth) {
proxyJVMArgs += ` -Dhttp.proxyUser=${proxySettings.auth.username} -Dhttp.proxyPassword=${proxySettings.auth.password} `;
proxyJVMArgs += ` -Dhttp.proxyUser=${proxySettings.auth.username} -Dhttp.proxyPassword=${proxySettings.auth.password}`
+ ` -Dhttps.proxyUser=${proxySettings.auth.username} -Dhttps.proxyPassword=${proxySettings.auth.password} `;
}
return proxyJVMArgs;
}
Expand Down

0 comments on commit 0f80194

Please sign in to comment.