Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpcomponents Wiki" 
for change notification.

The following page has been changed by OlegKalnichevski:
http://wiki.apache.org/HttpComponents/HttpClientTutorial

------------------------------------------------------------------------------
    
  == HTTP connection routing ==
  
-     HttpClient can establish connections to the target host either directly 
or via a complex route that involves multiple intermediate connections also 
referred to as hops. HttpClient differentiates connections of a route into 
plain, tunneled and layered.   
+     HttpClient can establish connections to the target host either directly 
or via a complex route that involves multiple intermediate connections also 
referred to as hops. HttpClient differentiates connections of a route into 
plain, tunneled and layered. The use of multiple intermediate proxies to tunnel 
connections to the target host is referred to as proxy chaining.
      
-     Plain routes are established by connecting to the target or the first 
proxy. Tunnelled routes are established by connecting to the first and 
tunnelling through all proxies to the target. Routes without a proxy cannot be 
tunnelled. Layered routes are established by layering a protocol over an 
existing connection. Protocols can only be layered over a tunnel to the target, 
or or over a direct connection without proxies.
+     Plain routes are established by connecting to the target or the first 
proxy. Tunnelled routes are established by connecting to the first and 
tunnelling through a chain of proxies to the target. Routes without a proxy 
cannot be tunnelled. Layered routes are established by layering a protocol over 
an existing connection. Protocols can only be layered over a tunnel to the 
target, or over a direct connection without proxies.
  
  === Route computation ===
  
@@ -704, +704 @@

  
      * '''http.route.forced-route''': defines an forced route to be used by 
all default route planner. Instead of computing a route, the given forced route 
will be returned, even if it points to a completely different target host. This 
parameter expects a value of type HttpRoute.
  
+ == Socket factories ==
- === Proxy chaining ===
- 
-     HttpClient is aware of the fact that there can be multiple intermediate 
proxies involved in establishing an end to end connection to the target host. 
This kind of technique is referred to as proxy chaining. 
  
  === Secure HTTP connections ===
  
      HTTP connections can be considered secure if information transmitted 
between two connection endpoints cannot be read or tampered with by 
unauthorized third party. The SSL/TLS protocol is the most widely used 
technique to ensure HTTP transport security. However, other encryption 
techniques could be employed as well. Usually, HTTP transport is layered over 
the SSL/TLS encrypted connection.
+ 
+ == HttpClient proxy configuration ==
+ 
+     Even though HttpClient is aware of complex routing scemes and proxy 
chaining, it supports only simple direct or one hop proxy connections out of 
the box.
+ 
+     The simplest way to tell HttpClient to connect to the target host via a 
proxy is by setting the default proxy parameter:
+ 
+ {{{
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ 
+ HttpHost proxy = new HttpHost("someproxy", 8080);
+ httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
+ }}}
+ 
+    One can also instruct HttpClient to use standard JRE proxy selector to 
obtain proxy information:
+ 
+ {{{
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ 
+ ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
+         httpclient.getConnectionManager().getSchemeRegistry(),
+         ProxySelector.getDefault());  
+ httpclient.setRoutePlanner(routePlanner);
+ }}}
+ 
+    Alternatively, one can provide a custom RoutePlanner implementation in 
order to have a complete control over the process of HTTP route computation:
+ 
+ {{{
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ httpclient.setRoutePlanner(new HttpRoutePlanner() {
+ 
+     public HttpRoute determineRoute(
+             HttpHost target, 
+             HttpRequest request, 
+             HttpContext context) throws HttpException {
+         return new HttpRoute(target, null,  new HttpHost("someproxy", 8080), 
+                 "https".equalsIgnoreCase(target.getSchemeName()));
+     }
+     
+ });
+ }}}
  
  == Managed connections ==
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to