com.isomorphic.servlet
Class HttpProxyServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.isomorphic.servlet.BaseServlet
                    |
                    +--com.isomorphic.servlet.HttpProxyServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class HttpProxyServlet
extends com.isomorphic.servlet.BaseServlet

The HttpProxyServlet proxies http requests for the client (browser) - typically for web service calls where cross-domain restictions prevent the browser from making a direct call to a particular URL. SmartClient automatically determines when a request is cross-domain and uses this servlet to make the request.

You can use a set of regular expressions to restrict the list of URLs that this servlet will proxy to. You can specify these win web.xml using the rules init-param or in a separate file. See the rules and rulesFile javadoc below. If no rules are specified, this filter will proxy to any URL requested by the client. If at least one rule is specified, then any URLs not matching the set of rules is disallowed.

See Also:
Serialized Form

Field Summary
 boolean acceptInvalidAndExpiredSSLCertificates
          If set to true, the proxy will accept invalid and expired SSL certificates from the proxied URL.
 java.lang.String proxyHost
          If outbound HTTP requests from this proxy must go through a proxy, you can set the hostname of the proxy server via this parameter.
 int proxyPort
          If outbound HTTP requests from this proxy must go through a proxy, you can set the port of the proxy server via this parameter.
protected  java.util.List rules
          You can specify the set of URLs proxyable by this servlet inline in web.xml.
 java.lang.String rulesFile
          Specifies path to a file that contains a set of regexp rules that constrain what URLs this servlet will proxy to.
 int urlCacheSize
          Specifies the size of the URLCache.
 boolean useURLCache
          This parameter controls whether the URLCache is enabled or not.
 

Field Detail

proxyHost

public java.lang.String proxyHost
If outbound HTTP requests from this proxy must go through a proxy, you can set the hostname of the proxy server via this parameter.

If the JVM executing this servlet can make direct HTTP connections to the relevant hosts, leave this parameter unset.


rulesFile

public java.lang.String rulesFile
Specifies path to a file that contains a set of regexp rules that constrain what URLs this servlet will proxy to. The format of the rulesFile is a list of regular expressions in a JSON array. For example:
 var rules = [
    "match:#http://www.slashdot.org/#",
 ];
 
Note: The rulesFile path is treated as relative to webRoot.

useURLCache

public boolean useURLCache
This parameter controls whether the URLCache is enabled or not.

If this servlet users regular expressions via the rulesFile, the URL Cache will cache the result of the application of relevant rules for any given URL. The URL Cache drastically speeds up subsequent rule applications at the cost of memory.

Note: the cache is automatically disabled if there are no rules to apply. Performance: The URL cache is an LRU Map. If you're using this servlet on a large-scale site with a lot of unique URLs, you may want to tune its size via the urlCacheSize parameter to balance between memory usage and performance.

See Also:
urlCacheSize

urlCacheSize

public int urlCacheSize
Specifies the size of the URLCache. Note that each servlet definition will have its own URLCache.

rules

protected java.util.List rules
You can specify the set of URLs proxyable by this servlet inline in web.xml. To do so, place the rules one to a line (newline separated) under the rules init-param of this servlet. For example:
 <servlet>
   <servlet-name>HttpProxyServlet</filter-name>
   <filter-class>com.isomorphic.servlet.HttpProxyServlet</filter-class>
   <init-param>
       <param-name>rules</param-name>
       <param-value>
           match:|http://www.slashdot.org/|
       </param-value>
   </init-param>
 </filter>
 
See Also:
rulesFile

acceptInvalidAndExpiredSSLCertificates

public boolean acceptInvalidAndExpiredSSLCertificates
If set to true, the proxy will accept invalid and expired SSL certificates from the proxied URL. If false (the default), an error is returned if the proxied URL is SSL-based and the certification is invalid or expired.

proxyPort

public int proxyPort
If outbound HTTP requests from this proxy must go through a proxy, you can set the port of the proxy server via this parameter.

If the JVM executing this servlet can make direct HTTP connections to the relevant hosts, leave this parameter unset.