camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "willem jiang (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > HTTP4
Date Wed, 30 Oct 2013 08:14:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/HTTP4">HTTP4</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~njiang">willem jiang</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        CAMEL-6786<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{x509HostnameVerifier}} | {{BrowserCompatHostnameVerifier}} | *Camel 2.7:* You can refer to a different {{org.apache.http.conn.ssl.X509HostnameVerifier}} instance in the [Registry] such as {{org.apache.http.conn.ssl.StrictHostnameVerifier}} or {{org.apache.http.conn.ssl.AllowAllHostnameVerifier}}. | <br>| {{connectionTimeToLive}} | {{-1}} | *Camel 2.11.0:* The time for connection to live, the time unit is millisecond, the default value is always keep alive. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">| {{authenticationPreemptive}} | {{false}} | *Camel 2.11.3/2.12.2:* If this option is true, camel-http4 sends preemptive basic authentication to the server. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="HTTP4-HTTP4Component"></a>HTTP4 Component</h2>

<p><b>Available as of Camel 2.3</b></p>

<p>The <b>http4:</b> component provides HTTP based <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">endpoints</a> for calling external HTTP resources (as a client to call external servers using HTTP).</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt> for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-http4&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>camel-http4 vs camel-http</b><br />Camel-http4 uses HttpClient 4.x while camel-http uses HttpClient 3.x.</td></tr></table></div>

<h3><a name="HTTP4-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
http4:hostname[:port][/resourceUri][?options]
</pre>
</div></div>
<p>Will by default use port 80 for HTTP and 443 for HTTPS.</p>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>camel-http4 vs camel-jetty</b><br />You can only produce to endpoints generated by the HTTP4 component. Therefore it should never be used as input into your Camel Routes. To bind/expose an HTTP endpoint via a HTTP server as input to a Camel route, use the <a href="/confluence/display/CAMEL/Jetty" title="Jetty">Jetty Component</a> instead.</td></tr></table></div>

<h3><a name="HTTP4-HttpComponentOptions"></a>HttpComponent Options</h3>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>maxTotalConnections</tt> </td>
<td class='confluenceTd'> <tt>200</tt> </td>
<td class='confluenceTd'> The maximum number of connections. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>connectionsPerRoute</tt> </td>
<td class='confluenceTd'> <tt>20</tt> </td>
<td class='confluenceTd'> The maximum number of connections per route. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>cookieStore</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.2/2.12.0:</b> To use a custom <tt>org.apache.http.client.CookieStore</tt>. By default the <tt>org.apache.http.impl.client.BasicCookieStore</tt> is used which is an in-memory only cookie store. Notice if <tt>bridgeEndpoint=true</tt> then the cookie store is forced to be a noop cookie store as cookies shouldn't be stored as we are just bridging (eg acting as a proxy). </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpClientConfigurer</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>clientConnectionManager</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To use a custom <tt>org.apache.http.conn.ClientConnectionManager</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpBinding</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To use a custom <tt>org.apache.camel.component.http.HttpBinding</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpContext</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.9.2:</b> To use a custom <tt>org.apache.http.protocol.HttpContext</tt> when executing requests. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sslContextParameters</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.8:</b> To use a custom <tt>org.apache.camel.util.jsse.SSLContextParameters</tt>. See <a href="#HTTP4-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</a>. <b>Important:</b> Only one instance of <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need. See further below for more details. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>x509HostnameVerifier</tt> </td>
<td class='confluenceTd'> <tt>BrowserCompatHostnameVerifier</tt> </td>
<td class='confluenceTd'> <b>Camel 2.7:</b> You can refer to a different <tt>org.apache.http.conn.ssl.X509HostnameVerifier</tt> instance in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> such as <tt>org.apache.http.conn.ssl.StrictHostnameVerifier</tt> or <tt>org.apache.http.conn.ssl.AllowAllHostnameVerifier</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>connectionTimeToLive</tt> </td>
<td class='confluenceTd'> <tt>-1</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.0:</b> The time for connection to live, the time unit is millisecond, the default value is always keep alive. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>authenticationPreemptive</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.3/2.12.2:</b> If this option is true, camel-http4 sends preemptive basic authentication to the server. </td>
</tr>
</tbody></table>
</div>
</div>


<h3><a name="HTTP4-HttpEndpointOptions"></a>HttpEndpoint Options</h3>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>throwExceptionOnFailure</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Option to disable throwing the <tt>HttpOperationFailedException</tt> in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>bridgeEndpoint</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If true, HttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set the <b>throwExcpetionOnFailure</b> to be false to let the HttpProducer send all fault responses back. Also if set to true HttpProducer and CamelServlet will skip the gzip processing if the content-encoding is "gzip". </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>clearExpiredCookies</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.2/2.12.0:</b> Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expired. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>cookieStore</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.2/2.12.0:</b> To use a custom <tt>org.apache.http.client.CookieStore</tt>. By default the <tt>org.apache.http.impl.client.BasicCookieStore</tt> is used which is an in-memory only cookie store. Notice if <tt>bridgeEndpoint=true</tt> then the cookie store is forced to be a noop cookie store as cookies shouldn't be stored as we are just bridging (eg acting as a proxy). </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>disableStreamCache</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> DefaultHttpBinding will copy the request input stream into a stream cache and put it into the message body if this option is false to support multiple reads, otherwise DefaultHttpBinding will set the request input stream directly in the message body. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>headerFilterStrategy</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.10.4:</b> Reference to a instance of <tt>org.apache.camel.spi.HeaderFilterStrategy</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.&nbsp;It will be used to apply the custom headerFilterStrategy on the new create HttpEndpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpBindingRef</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Deprecated and will be removed in Camel 3.0:</b> Reference to a <tt>org.apache.camel.component.http.HttpBinding</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. Use the <tt>httpBinding</tt> option instead. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpBinding</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To use a custom <tt>org.apache.camel.component.http.HttpBinding</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpClientConfigurerRef</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Deprecated and will be removed in Camel 3.0:</b> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. Use the <tt>httpClientConfigurer</tt> option instead. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpClientConfigurer</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Reference to a <tt>org.apache.camel.component.http.HttpClientConfigurer</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpContextRef</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Deprecated and will be removed in Camel 3.0:</b> <b>Camel 2.9.2:</b> Reference to a custom <tt>org.apache.http.protocol.HttpContext</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. Use the <tt>httpContext</tt> option instead. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpContext</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.9.2:</b> To use a custom <tt>org.apache.http.protocol.HttpContext</tt> when executing requests. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpClient.XXX</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Setting options on the <a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/BasicHttpParams.html" class="external-link" rel="nofollow">BasicHttpParams</a>. For instance <tt>httpClient.soTimeout=5000</tt> will set the <tt>SO_TIMEOUT</tt> to 5 seconds. Look on the setter methods of the following parameter beans for a complete reference: <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/auth/params/AuthParamBean.html" class="external-link" rel="nofollow">AuthParamBean</a>, <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/params/ClientParamBean.html" class="external-link" rel="nofollow">ClientParamBean</a>, <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnConnectionParamBean.html" class="external-link" rel="nofollow">ConnConnectionParamBean</a>, <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/params/ConnRouteParamBean.html" class="external-link" rel="nofollow">ConnRouteParamBean</a>, <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/cookie/params/CookieSpecParamBean.html" class="external-link" rel="nofollow">CookieSpecParamBean</a>, <a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpConnectionParamBean.html" class="external-link" rel="nofollow">HttpConnectionParamBean</a> and <a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/HttpProtocolParamBean.html" class="external-link" rel="nofollow">HttpProtocolParamBean</a> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>clientConnectionManager</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To use a custom <tt>org.apache.http.conn.ClientConnectionManager</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transferException</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If enabled and an <a href="/confluence/display/CAMEL/Exchange" title="Exchange">Exchange</a> failed processing on the consumer side, and if the caused <tt>Exception</tt> was send back serialized in the response as a <tt>application/x-java-serialized-object</tt> content type (for example using <a href="/confluence/display/CAMEL/Jetty" title="Jetty">Jetty</a> or <a href="/confluence/display/CAMEL/SERVLET" title="SERVLET">SERVLET</a> Camel components). On the producer side the exception will be deserialized and thrown as is, instead of the <tt>HttpOperationFailedException</tt>. The caused exception is required to be serialized. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sslContextParametersRef</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Deprecated and will be removed in Camel 3.0:</b> <b>Camel 2.8:</b> Reference to a <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.  <b>Important:</b> Only one instance of <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need. See further below for more details. See <a href="#HTTP4-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</a>. Use the <tt>sslContextParameters</tt> option instead. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sslContextParameters</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.1:</b> Reference to a <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.  <b>Important:</b> Only one instance of <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need. See further below for more details. See <a href="#HTTP4-UsingtheJSSEConfigurationUtility">Using the JSSE Configuration Utility</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>x509HostnameVerifier</tt> </td>
<td class='confluenceTd'> <tt>BrowserCompatHostnameVerifier</tt> </td>
<td class='confluenceTd'> <b>Camel 2.7:</b> You can refer to a different <tt>org.apache.http.conn.ssl.X509HostnameVerifier</tt> instance in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> such as <tt>org.apache.http.conn.ssl.StrictHostnameVerifier</tt> or <tt>org.apache.http.conn.ssl.AllowAllHostnameVerifier</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>urlRewrite</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11:</b> <b>Producer only</b> Refers to a custom <tt>org.apache.camel.component.http4.UrlRewrite</tt> which allows you to rewrite urls when you bridge/proxy endpoints. See more details at <a href="/confluence/display/CAMEL/UrlRewrite" title="UrlRewrite">UrlRewrite</a> and <a href="/confluence/display/CAMEL/How+to+use+Camel+as+a+HTTP+proxy+between+a+client+and+server" title="How to use Camel as a HTTP proxy between a client and server">How to use Camel as a HTTP proxy between a client and server</a>. </td>
</tr>
</tbody></table>
</div>
</div>

<p>The following authentication options can also be set on the HttpEndpoint:</p>

<h4><a name="HTTP4-SettingBasicAuthenticationandProxy"></a>Setting Basic Authentication and Proxy</h4>

<p><b>Before Camel 2.8.0</b></p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>username</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Username for authentication. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>password</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Password for authentication. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>domain</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The domain name for authentication. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>host</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The host name authentication. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyHost</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy host name </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyPort</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy port number </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyUsername</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Username for proxy authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyPassword</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Password for proxy authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyDomain</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy domain name </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyNtHost</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy Nt host name </td>
</tr>
</tbody></table>
</div>
</div>
<p><b>Since Camel 2.8.0</b></p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>authUsername</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Username for authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>authPassword</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Password for authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>authDomain</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The domain name for authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>authHost</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The host name authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthHost</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy host name </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthPort</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy port number </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthScheme</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy scheme, will fallback and use the scheme from the endpoint if not configured. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthUsername</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Username for proxy authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthPassword</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Password for proxy authentication </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthDomain</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy domain name </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>proxyAuthNtHost</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> The proxy Nt host name </td>
</tr>
</tbody></table>
</div>
</div>


<h3><a name="HTTP4-MessageHeaders"></a>Message Headers</h3>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.HTTP_URI</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> URI to call. Will override existing URI set directly on the endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.HTTP_PATH</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Request URI's path, the header will be used to build the request URI with the HTTP_URI. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.HTTP_QUERY</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> URI parameters. Will override existing URI parameters set directly on the endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.HTTP_RESPONSE_CODE</tt> </td>
<td class='confluenceTd'> <tt>int</tt> </td>
<td class='confluenceTd'> The HTTP response code from the external server. Is 200 for OK. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.HTTP_CHARACTER_ENCODING</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Character encoding. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.CONTENT_TYPE</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The HTTP content type. Is set on both the IN and OUT message to provide a content type, such as <tt>text/html</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Exchange.CONTENT_ENCODING</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The HTTP content encoding. Is set on both the IN and OUT message to provide a content encoding, such as <tt>gzip</tt>. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="HTTP4-MessageBody"></a>Message Body</h3>

<p>Camel will store the HTTP response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message, so headers are preserved during routing. Additionally Camel will add the HTTP response headers as well to the OUT message headers.</p>

<h3><a name="HTTP4-Responsecode"></a>Response code</h3>

<p>Camel will handle according to the HTTP response code:</p>
<ul class="alternate" type="square">
	<li>Response code is in the range 100..299, Camel regards it as a success response.</li>
	<li>Response code is in the range 300..399, Camel regards it as a redirection response and will throw a <tt>HttpOperationFailedException</tt> with the information.</li>
	<li>Response code is 400+, Camel regards it as an external server failure and will throw a <tt>HttpOperationFailedException</tt> with the information.
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>throwExceptionOnFailure</b><br />The option, <tt>throwExceptionOnFailure</tt>, can be set to <tt>false</tt> to prevent the <tt>HttpOperationFailedException</tt> from being thrown for failed response codes. This allows you to get any response from the remote server.<br/>
There is a sample below demonstrating this.</td></tr></table></div></li>
</ul>


<h3><a name="HTTP4-HttpOperationFailedException"></a>HttpOperationFailedException</h3>

<p>This exception contains the following information:</p>
<ul class="alternate" type="square">
	<li>The HTTP status code</li>
	<li>The HTTP status line (text of the status code)</li>
	<li>Redirect location, if server returned a redirect</li>
	<li>Response body as a <tt>java.lang.String</tt>, if server provided a body as response</li>
</ul>


<h3><a name="HTTP4-CallingusingGETorPOST"></a>Calling using GET or POST</h3>

<p>The following algorithm is used to determine whether the <tt>GET</tt> or <tt>POST</tt> HTTP method should be used:<br/>
1. Use method provided in header.<br/>
2. <tt>GET</tt> if query string is provided in header.<br/>
3. <tt>GET</tt> if endpoint is configured with a query string.<br/>
4. <tt>POST</tt> if there is data to send (body is not null).<br/>
5. <tt>GET</tt> otherwise.</p>

<h3><a name="HTTP4-HowtogetaccesstoHttpServletRequestandHttpServletResponse"></a>How to get access to HttpServletRequest and HttpServletResponse</h3>

<p>You can get access to these two using the Camel type converter system using<br/>
<b>NOTE</b> You can get the request and response not just from the processor after the camel-jetty or camel-cxf endpoint.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
HttpServletRequest response = exchange.getIn().getBody(HttpServletResponse.class);
</pre>
</div></div>

<h3><a name="HTTP4-ConfiguringURItocall"></a>Configuring URI to call</h3>

<p>You can set the HTTP producer's URI directly form the endpoint URI. In the route below, Camel will call out to the external server, <tt>oldhost</tt>, using HTTP.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
	    .to("http4://oldhost");
</pre>
</div></div>
<p>And the equivalent Spring sample:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;camelContext xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;route&gt;
    &lt;from uri="direct:start"/&gt;
    &lt;to uri="http4://oldhost"/&gt;
  &lt;/route&gt;
&lt;/camelContext&gt;
</pre>
</div></div>

<p>You can override the HTTP endpoint URI by adding a header with the key, <tt>Exchange.HTTP_URI</tt>, on the message.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
  .setHeader(Exchange.HTTP_URI, constant("http://newhost"))
  .to("http4://oldhost");
</pre>
</div></div>
<p>In the sample above Camel will call the <a href="http://newhost" class="external-link" rel="nofollow">http://newhost</a> despite the endpoint is configured with <a href="http4://oldhost" class="external-link" rel="nofollow">http4://oldhost</a>.<br/>
Where Constants is the class, <tt>org.apache.camel.component.http4.Constants</tt>.<br/>
If the http4 endpoint is working in bridge mode, it will ignore the message header of <tt>Exchange.HTTP_URI</tt>.</p>

<h3><a name="HTTP4-ConfiguringURIParameters"></a>Configuring URI Parameters</h3>

<p>The <b>http</b> producer supports URI parameters to be sent to the HTTP server. The URI parameters can either be set directly on the endpoint URI or as a header with the key <tt>Exchange.HTTP_QUERY</tt> on the message.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
  .to("http4://oldhost?order=123&amp;detail=short");
</pre>
</div></div>
<p>Or options provided in a header:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
  .setHeader(Exchange.HTTP_QUERY, constant("order=123&amp;detail=short"))
  .to("http4://oldhost");
</pre>
</div></div>


<h3><a name="HTTP4-Howtosetthehttpmethod%28GET%2FPATCH%2FPOST%2FPUT%2FDELETE%2FHEAD%2FOPTIONS%2FTRACE%29totheHTTPproducer"></a>How to set the http method (GET/PATCH/POST/PUT/DELETE/HEAD/OPTIONS/TRACE) to the HTTP producer</h3>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Using the http PATCH method</b><br />The http PATCH method is supported starting with Camel 2.11.3 / 2.12.1.</td></tr></table></div>

<p>The HTTP4 component provides a way to set the HTTP request method by setting the message header. Here is an example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
  .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
  .to("http4://www.google.com")
  .to("mock:results");
</pre>
</div></div>

<p>The method can be written a bit shorter using the string constants:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
.setHeader("CamelHttpMethod", constant("POST"))
</pre>
</div></div>

<p>And the equivalent Spring sample:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;camelContext xmlns="http://activemq.apache.org/camel/schema/spring"&gt;
  &lt;route&gt;
    &lt;from uri="direct:start"/&gt;
    &lt;setHeader headerName="CamelHttpMethod"&gt;
        &lt;constant&gt;POST&lt;/constant&gt;
    &lt;/setHeader&gt;
    &lt;to uri="http4://www.google.com"/&gt;
    &lt;to uri="mock:results"/&gt;
  &lt;/route&gt;
&lt;/camelContext&gt;
</pre>
</div></div>

<h3><a name="HTTP4-UsingclienttimeoutSOTIMEOUT"></a>Using client timeout - SO_TIMEOUT</h3>

<p>See the <a href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpSOTimeoutTest.java" class="external-link" rel="nofollow">HttpSOTimeoutTest</a> unit test.</p>


<h3><a name="HTTP4-ConfiguringaProxy"></a>Configuring a Proxy</h3>

<p>The HTTP4 component provides a way to configure a proxy.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("direct:start")
  .to("http4://oldhost?proxyAuthHost=www.myproxy.com&amp;proxyAuthPort=80");
</pre>
</div></div>

<p>There is also support for proxy authentication via the <tt>proxyAuthUsername</tt> and <tt>proxyAuthPassword</tt> options.</p>

<h4><a name="HTTP4-UsingproxysettingsoutsideofURI"></a>Using proxy settings outside of URI</h4>

<p>To avoid System properties conflicts, you can set proxy configuration only from the CamelContext or URI.<br/>
Java DSL :</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
 context.getProperties().put("http.proxyHost", "172.168.18.9");
 context.getProperties().put("http.proxyPort" "8080");
</pre>
</div></div>
<p>Spring XML</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
   &lt;camelContext&gt;
       &lt;properties&gt;
           &lt;property key="http.proxyHost" value="172.168.18.9"/&gt;
           &lt;property key="http.proxyPort" value="8080"/&gt;
      &lt;/properties&gt;
   &lt;/camelContext&gt;
</pre>
</div></div>
<p>Camel will first set the settings from Java System or CamelContext Properties and then the endpoint proxy options if provided.<br/>
So you can override the system properties with the endpoint options.</p>

<p>Notice in <b>Camel 2.8</b> there is also a <tt>http.proxyScheme</tt> property you can set to explicit configure the scheme to use.</p>

<h3><a name="HTTP4-Configuringcharset"></a>Configuring charset</h3>

<p>If you are using <tt>POST</tt> to send data you can configure the <tt>charset</tt> using the <tt>Exchange</tt> property:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
</pre>
</div></div>

<h4><a name="HTTP4-Samplewithscheduledpoll"></a>Sample with scheduled poll</h4>

<p>This sample polls the Google homepage every 10 seconds and write the page to the file <tt>message.html</tt>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
from("timer://foo?fixedRate=true&amp;delay=0&amp;period=10000")
  .to("http4://www.google.com")
  .setHeader(FileComponent.HEADER_FILE_NAME, "message.html")
  .to("file:target/google");
</pre>
</div></div>

<h4><a name="HTTP4-URIParametersfromtheendpointURI"></a>URI Parameters from the endpoint URI</h4>

<p>In this sample we have the complete URI endpoint that is just what you would have typed in a web browser. Multiple URI parameters can of course be set using the <tt>&amp;</tt> character as separator, just as you would in the web browser. Camel does no tricks here.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
// we query for Camel at the Google page
template.sendBody("http4://www.google.com/search?q=Camel", null);
</pre>
</div></div>

<h4><a name="HTTP4-URIParametersfromtheMessage"></a>URI Parameters from the Message</h4>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
Map headers = new HashMap();
headers.put(HttpProducer.QUERY, "q=Camel&amp;lr=lang_en");
// we query for Camel and English language at Google
template.sendBody("http4://www.google.com/search", null, headers);
</pre>
</div></div>
<p>In the header value above notice that it should <b>not</b> be prefixed with <tt>?</tt> and you can separate parameters as usual with the <tt>&amp;</tt> char.</p>

<h4><a name="HTTP4-GettingtheResponseCode"></a>Getting the Response Code</h4>

<p>You can get the HTTP response code from the HTTP4 component by getting the value from the Out message header with <tt>HttpProducer.HTTP_RESPONSE_CODE</tt>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
Exchange exchange = template.send("http4://www.google.com/search", new Processor() {
  public void process(Exchange exchange) throws Exception {
    exchange.getIn().setHeader(HttpProducer.QUERY, constant("hl=en&amp;q=activemq"));
  }
});
Message out = exchange.getOut();
int responseCode = out.getHeader(HttpProducer.HTTP_RESPONSE_CODE, Integer.class);
</pre>
</div></div>

<h3><a name="HTTP4-DisablingCookies"></a>Disabling Cookies</h3>

<p>To disable cookies you can set the HTTP Client to ignore cookies by adding this URI option:<br/>
<tt>httpClient.cookiePolicy=ignoreCookies</tt></p>

<h3><a name="HTTP4-AdvancedUsage"></a>Advanced Usage</h3>

<p>If you need more control over the HTTP producer you should use the <tt>HttpComponent</tt> where you can set various classes to give you custom behavior.</p>

<h4><a name="HTTP4-SettingupSSLforHTTPClient"></a>Setting up SSL for HTTP Client</h4>

<h5><a name="HTTP4-UsingtheJSSEConfigurationUtility"></a>Using the JSSE Configuration Utility</h5>

<p>As of Camel 2.8, the HTTP4 component supports SSL/TLS configuration through the <a href="/confluence/display/CAMEL/Camel+Configuration+Utilities" title="Camel Configuration Utilities">Camel JSSE Configuration Utility</a>.&nbsp; This utility greatly decreases the amount of component specific code you need to write and is configurable at the endpoint and component levels.&nbsp; The following examples demonstrate how to use the utility with the HTTP4 component.</p>

<h6><a name="HTTP4-Programmaticconfigurationofthecomponent"></a>Programmatic configuration of the component</h6>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("/users/home/server/keystore.jks");
ksp.setPassword("keystorePassword");

KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
kmp.setKeyPassword("keyPassword");

SSLContextParameters scp = new SSLContextParameters();
scp.setKeyManagers(kmp);

HttpComponent httpComponent = getContext().getComponent("http4", HttpComponent.class);
httpComponent.setSslContextParameters(scp);
</pre>
</div></div>

<h6><a name="HTTP4-SpringDSLbasedconfigurationofendpoint"></a>Spring DSL based configuration of endpoint</h6>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
...
  &lt;camel:sslContextParameters
      id="sslContextParameters"&gt;
    &lt;camel:keyManagers
        keyPassword="keyPassword"&gt;
      &lt;camel:keyStore
          resource="/users/home/server/keystore.jks"
          password="keystorePassword"/&gt;
    &lt;/camel:keyManagers&gt;
  &lt;/camel:sslContextParameters&gt;...
...
  &lt;to uri="https4://127.0.0.1/mail/?sslContextParametersRef=sslContextParameters"/&gt;...
</pre>
</div></div>

<h5><a name="HTTP4-ConfiguringApacheHTTPClientDirectly"></a>Configuring Apache HTTP Client Directly</h5>

<p>Basically camel-http4 component is built on the top of <a href="http://hc.apache.org/" class="external-link" rel="nofollow">Apache HTTP client</a>. Please refer to <a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e537" class="external-link" rel="nofollow">SSL/TLS customization</a> for details or have a look into the <tt>org.apache.camel.component.http4.HttpsServerTestSupport</tt> unit test base class.<br/>
You can also implement a custom <tt>org.apache.camel.component.http4.HttpClientConfigurer</tt> to do some configuration on the http client if you need full control of it.</p>

<p>However if you <em>just</em> want to specify the keystore and truststore you can do this with Apache HTTP <tt>HttpClientConfigurer</tt>, for example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
KeyStore keystore = ...;
KeyStore truststore = ...;

SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 443, new SSLSocketFactory(keystore, "mypassword", truststore)));
</pre>
</div></div>

<p>And then you need to create a class that implements <tt>HttpClientConfigurer</tt>, and registers https protocol providing a keystore or truststore per example above. Then, from your camel route builder class you can hook it up like so:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
HttpComponent httpComponent = getContext().getComponent("http4", HttpComponent.class);
httpComponent.setHttpClientConfigurer(new MyHttpClientConfigurer());
</pre>
</div></div>

<p>If you are doing this using the Spring DSL, you can specify your <tt>HttpClientConfigurer</tt> using the URI.  For example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;bean id="myHttpClientConfigurer"
 class="my.https.HttpClientConfigurer"&gt;
&lt;/bean&gt;

&lt;to uri="https4://myhostname.com:443/myURL?httpClientConfigurer=myHttpClientConfigurer"/&gt;
</pre>
</div></div>

<p>As long as you implement the HttpClientConfigurer and configure your keystore and truststore as described above, it will work fine.</p>

<h5><a name="HTTP4-UsingHTTPStoauthenticategotchas"></a>Using HTTPS to authenticate gotchas</h5>

<p>An end user reported that he had problem with authenticating with HTTPS. The problem was eventually resolved by providing a custom configured <tt>org.apache.http.protocol.HttpContext</tt>:</p>

<p>1. Create a (Spring) factory for HttpContexts:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
public class HttpContextFactory {

  private String httpHost = "localhost";
  private String httpPort = 9001;

  private BasicHttpContext httpContext = new BasicHttpContext();
  private BasicAuthCache authCache = new BasicAuthCache();
  private BasicScheme basicAuth = new BasicScheme();

  public HttpContext getObject() {
    authCache.put(new HttpHost(httpHost, httpPort), basicAuth);

    httpContext.setAttribute(ClientContext.AUTH_CACHE, authCache);

    return httpContext;
  }

  // getter and setter
}
</pre>
</div></div>
<p>2. Declare an HttpContext in the Spring application context file:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;bean id="myHttpContext" factory-bean="httpContextFactory" factory-method="getObject"/&gt;
</pre>
</div></div>
<p>3. Reference the context in the http4 URL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;to uri="https4://myhostname.com:443/myURL?httpContext=myHttpContext"/&gt;
</pre>
</div></div>

<h5><a name="HTTP4-UsingdifferentSSLContextParameters"></a>Using different SSLContextParameters</h5>

<p>The <a href="/confluence/display/CAMEL/HTTP4" title="HTTP4">HTTP4</a> component only support one instance of <tt>org.apache.camel.util.jsse.SSLContextParameters</tt> per component. If you need to use 2 or more different instances, then you need to setup multiple <a href="/confluence/display/CAMEL/HTTP4" title="HTTP4">HTTP4</a> components as shown below. Where we have 2 components, each using their own instance of <tt>sslContextParameters</tt> property.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;bean id="http4-foo" class="org.apache.camel.component.http4.HttpComponent"&gt;
   &lt;property name="sslContextParameters" ref="sslContextParams1"/&gt;
   &lt;property name="x509HostnameVerifier" ref="hostnameVerifier"/&gt;
&lt;/bean&gt;

&lt;bean id="http4-bar" class="org.apache.camel.component.http4.HttpComponent"&gt;
   &lt;property name="sslContextParameters" ref="sslContextParams2"/&gt;
   &lt;property name="x509HostnameVerifier" ref="hostnameVerifier"/&gt;
&lt;/bean&gt;
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/HTTP4">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=25200246&revisedVersion=25&originalVersion=24">View Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message