Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-httpclient Wiki" for change notification.
The following page has been changed by RolandWeber: http://wiki.apache.org/jakarta-httpclient/FrequentlyAskedApplicationDesignQuestions The comment on the change is: updated "proxy configuration" section ------------------------------------------------------------------------------ [http://www.ietf.org/rfc/rfc3546.txt RFC 3546: Transport Layer Security (TLS) Extensions] + + ------- - == Client Through a Proxy == + == Proxy Configuration == - At this time, the system properties '''http.proxyHost''' and - '''http.proxyPort''', etc., have no affect on the proxy usage. Until - this functionality is added, you must specify the proxy information - at runtime, similarly to the following example: + HttpClient takes proxy configuration data from + [http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HostConfiguration.html HostConfiguration] + objects. These can either be passed explicitly when a method is executed (!HttpClient 3.1), or the default + configuration stored in the !HttpClient object is used. + Some of our users have the requirement to pick up external proxy configurations. + The following sections discuss some options for obtaining external proxy configuration data. + [[BR]] + Please note that !HttpClient is designed to yield predictable results for applications in need of an embedded + HTTP implementation. If !HttpClient would automatically pick up external configuration data, predictability + would be lost. Therefore, it remains the responsibility of the ''application'' to obtain proxy configuration data + and to pass it to !HttpClient. We will consider to provide helpers for this task if patches are contributed, + but the responsibility for calling such helpers would still remain with the application. + + + === System Properties === + + Up to and including Java 1.4, the standard Java implementation of HTTP, which is accessible through the + [http://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.html HttpURLConnection] + class, expects proxy configuration data in system properties. The names of the properties + that affect different protocols (HTTP, HTTPS, FTP,...) have changed over time. The two most + prominent examples are {{{http.proxyHost}}} and {{{http.proxyPort}}}. + You can read the values of these properties and supply the configuration as shown in the example below. + [[BR]] + Note that other properties will also affect the standard Java HTTP implementation, for example + a list of proxy exemptions in {{{http.nonProxyHost}}}. It is your application which must decide + whether the external proxy configuration is applicable or not. {{{ @@ -383, +407 @@ }}} + Since Java 5.0, the + [http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html ProxySelector] + class allows for a more flexible, per-connection proxy configuration of the default HTTP implementation. + Because !HttpClient 3.1 is compatible with Java 1.2 and !HttpClient 4.0 will probably be compatible with Java 1.4, + this class will not be directly supported by !HttpClient anytime soon. + However, your application can make use of the default {{{ProxySelector}}} to pick up the + standard proxy configuration and pass it it !HttpClient. + + + === Operating System Settings === + + On Linux and Unix systems, a proxy on the operating system level is typically set in environment variables. + The Java method for reading environment variables is + [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getenv(java.lang.String) System.getenv]. + Unfortunately, it is deprecated and not even implemented in some Java versions (JDK 1.4?). + The recommended replacement is to pass relevant environment variables as system properties by using + {{{-Dname=value}}} options when starting your application. See above for reading a proxy configuration + from system properties. Of course you can use custom property names in order to pass values without + affecting the default HTTP implementation. + [[BR]] + If using {{{-D}}} options is not feasible and you are stuck with a JVM that does not implement {{{System.getenv}}}, + you can try to run a shell script using + [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String%5b%5d) Runtime.exec]. + The shell script should print the relevant environment variables to standard output, from where your + application can parse them. + + On Windows systems, the proxy configuration is typically set in the registry. + You can either use + [http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html native code] + to read the registry, or try to run a shell script (batch file) as mentioned for the Linux/Unix case. + + ''If you know something about proxy settings on Mac OS, please share that information. + You can edit this Wiki page directly, or send a mail to one of our + [http://jakarta.apache.org/httpcomponents/mail-lists.html mailing lists].'' + + + === Browser Settings === + + When an applet uses + [http://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.html HttpURLConnection], + the Java plug-in running the applet will automatically pick up the proxy configuration of the browser, + and also cookies stored in the browser. This is described in the + [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/contents.html Java plug-in Developer Guide] + for JDK 1.4, + [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/proxie_config.html chapter 5] + and + [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/cookie_support.html chapter 7] + respectively. While this documentation explains the complexity of obtaining the proxy configuration, + it does not mention a public API from which an application could pick it up. + + Since Java 5.0, you can use the default + [http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html ProxySelector] + mentioned in the section on system properties above. When running in the Java plug-in, + it will provide access to the browser proxy configuration. + [[BR]] + ''If you know how to access the browser proxy configuration in previous versions of the Java plug-in, + please share that information. You can edit this Wiki page directly, or send a mail to one of our + [http://jakarta.apache.org/httpcomponents/mail-lists.html mailing lists].'' + [[BR]] + ''If you know how to access the browser cookie store from an applet, please share that information too. + Send a mail to one of our [http://jakarta.apache.org/httpcomponents/mail-lists.html mailing lists] + or start a new section in this Wiki page.'' + + + === Further Reading === + + [http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html Networking Properties], Java 1.4 + + [http://java.sun.com/j2se/1.5.0/docs/guide/net/proxies.html Java Networking and Proxies], Java 5.0 + + [http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html Java Native Interface] + + [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/index.html Java Plug-in], Java 1.4 + + [http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/proxie_config.html Proxy Configuration], Deployment Guide for Java 5.0 + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
