Package org.htmlunit

# Class ProxyConfig

java.lang.Object
org.htmlunit.ProxyConfig

All Implemented Interfaces:
  `Serializable`

public class ProxyConfig extends Object implements Serializable
Class which centralizes proxy configuration, in an effort to reduce clutter in the `WebClient` class. One instance of this class exists for each `WebClient` instance.

See Also:
  - `WebClientOptions.getProxyConfig()`
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProxyConfig()`
  Creates a new instance.
  `ProxyConfig(String proxyHost, int proxyPort, String proxyScheme)`
  Creates a new instance.
  `ProxyConfig(String proxyHost, int proxyPort, String proxyScheme, boolean isSocks)`
  Creates a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addHostsToProxyBypass(String pattern)`
  Any hosts matched by the specified regular expression pattern will bypass the configured proxy.
  `protected String`
  `getProxyAutoConfigContent()`
  Returns the proxy auto-config content.
  `String`
  `getProxyAutoConfigUrl()`
  Returns the proxy auto-config URL.
  `String`
  `getProxyHost()`
  Returns the proxy host used to perform HTTP requests.
  `int`
  `getProxyPort()`
  Returns the proxy port used to perform HTTP requests.
  `String`
  `getProxyScheme()`
  Returns the proxy scheme used to perform HTTP requests.
  `boolean`
  `isSocksProxy()`
  Returns whether SOCKS proxy or not.
  `void`
  `removeHostsFromProxyBypass(String pattern)`
  Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.
  `protected void`
  `setProxyAutoConfigContent(String proxyAutoConfigContent)`
  Sets the proxy auto-config content.
  `void`
  `setProxyAutoConfigUrl(String proxyAutoConfigUrl)`
  Sets the proxy auto-config URL.
  `void`
  `setProxyHost(String proxyHost)`
  Sets the proxy host used to perform HTTP requests.
  `void`
  `setProxyPort(int proxyPort)`
  Sets the proxy port used to perform HTTP requests.
  `void`
  `setProxyPort(String proxyScheme)`
  Sets the proxy scheme used to perform HTTP requests.
  `void`
  `setSocksProxy(boolean isSocksProxy)`
  Sets whether SOCKS proxy or not.
  `protected boolean`
  `shouldBypassProxy(String hostname)`
  Returns `true` if the host with the specified hostname should be accessed bypassing the configured proxy.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ProxyConfig

    public ProxyConfig()
    Creates a new instance.

  - ### ProxyConfig

    public ProxyConfig(String proxyHost, int proxyPort, String proxyScheme)
    Creates a new instance.
    Parameters:
      `proxyHost` - the proxy host
      `proxyPort` - the proxy port
      `proxyScheme` - the scheme http/https; null defaults to http

  - ### ProxyConfig

    public ProxyConfig(String proxyHost, int proxyPort, String proxyScheme, boolean isSocks)
    Creates a new instance.
    Parameters:
      `proxyHost` - the proxy host
      `proxyPort` - the proxy port
      `proxyScheme` - the scheme http/https
      `isSocks` - whether SOCKS proxy or not

- ## Method Details

  - ### getProxyHost

    public String getProxyHost()
    Returns the proxy host used to perform HTTP requests.
    Returns:
      the proxy host used to perform HTTP requests

  - ### setProxyHost

    public void setProxyHost(String proxyHost)
    Sets the proxy host used to perform HTTP requests.
    Parameters:
      `proxyHost` - the proxy host used to perform HTTP requests

  - ### getProxyPort

    public int getProxyPort()
    Returns the proxy port used to perform HTTP requests.
    Returns:
      the proxy port used to perform HTTP requests

  - ### setProxyPort

    public void setProxyPort(int proxyPort)
    Sets the proxy port used to perform HTTP requests.
    Parameters:
      `proxyPort` - the proxy port used to perform HTTP requests

  - ### getProxyScheme

    public String getProxyScheme()
    Returns the proxy scheme used to perform HTTP requests.
    Returns:
      the proxy scheme used to perform HTTP requests

  - ### setProxyPort

    public void setProxyPort(String proxyScheme)
    Sets the proxy scheme used to perform HTTP requests.
    Parameters:
      `proxyScheme` - the proxy scheme used to perform HTTP requests

  - ### isSocksProxy

    public boolean isSocksProxy()
    Returns whether SOCKS proxy or not.
    Returns:
      whether SOCKS proxy or not

  - ### setSocksProxy

    public void setSocksProxy(boolean isSocksProxy)
    Sets whether SOCKS proxy or not.
    Parameters:
      `isSocksProxy` - whether SOCKS proxy or not

  - ### addHostsToProxyBypass

    public void addHostsToProxyBypass(String pattern)
    Any hosts matched by the specified regular expression pattern will bypass the configured proxy.
    Parameters:
      `pattern` - a regular expression pattern that matches the hostnames of the hosts which should bypass the configured proxy.
    See Also:
      - `Pattern`

  - ### removeHostsFromProxyBypass

    public void removeHostsFromProxyBypass(String pattern)
    Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.
    Parameters:
      `pattern` - the previously added regular expression pattern
    See Also:
      - `Pattern`

  - ### shouldBypassProxy

    protected boolean shouldBypassProxy(String hostname)
    Returns `true` if the host with the specified hostname should be accessed bypassing the configured proxy.
    Parameters:
      `hostname` - the name of the host to check
    Returns:
      `true` if the host with the specified hostname should be accessed bypassing the configured proxy, `false` otherwise.

  - ### getProxyAutoConfigUrl

    public String getProxyAutoConfigUrl()
    Returns the proxy auto-config URL.
    Returns:
      the proxy auto-config URL

  - ### setProxyAutoConfigUrl

    public void setProxyAutoConfigUrl(String proxyAutoConfigUrl)
    Sets the proxy auto-config URL.
    Parameters:
      `proxyAutoConfigUrl` - the proxy auto-config URL

  - ### getProxyAutoConfigContent

    protected String getProxyAutoConfigContent()
    Returns the proxy auto-config content.
    Returns:
      the proxy auto-config content

  - ### setProxyAutoConfigContent

    protected void setProxyAutoConfigContent(String proxyAutoConfigContent)
    Sets the proxy auto-config content.
    Parameters:
      `proxyAutoConfigContent` - the proxy auto-config content