Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.18k stars 433 forks source link

excludeHostsForProxy - Variable should support trailing domain names #550

Open salvisbh opened 4 years ago

salvisbh commented 4 years ago

Currently the proxy configuration only allows a "stupid" list of hostnames for which the communication should be established without a proxy.

Example:

"rest-client.excludeHostsForProxy": [
        "127.0.0.1",
        "localhost",
        "mydomain.com"
    ]

Wildcards for domain suffixes do not seem to be possible. In large environments this means that for each subdomain or server an entry in settings.json must be explicitly added.

Lines 300 to 314 in httpClient.ts document this behavior.

       for (const eh of excludeHostsProxyList) {
            const urlParts = eh.split(":");
            if (!port) {
                // if no port specified in request url, host name must exactly match
                if (urlParts.length === 1 && urlParts[0] === hostName) {
                    return true;
                }
            } else {
                // if port specified, match host without port or hostname:port exactly match
                const [ph, pp] = urlParts;
                if (ph === hostName && (!pp || pp === port)) {
                    return true;
                }
            }
        }

It would be desirable to be able to use the same rules for trailing_domain as in the underlying chromium framework.

Extract from the documentation:

--proxy-bypass-list=(|)[:][;...]

This tells chrome to bypass any specified proxy for the given semi-colon-separated list of hosts. This flag must be used (or rather, only has an effect) in tandem with --proxy-server. Note that trailing-domain matching doesn't require "." separators so "*google.com" will match "igoogle.com" for example.

--- end documentation extract

This problem is closely related to the vscode issue Extension proxy support #12588

Huachao commented 4 years ago

@salvisbh one question, what's the setting of your setting http.proxySupport?