Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Java DSL

Code Block
languagejava
from("direct:start")
  .to("http://oldhost?order=123&detail=short");

from("direct:start")
  .setHeader(Exchange.HTTP_QUERY, constant("order=123&detail=short"))
  .to("http://oldhost");

...

Div
classconfluenceTableSmall

Name

Default Value

Description

throwExceptionOnFailure

true

Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.

bridgeEndpoint

false

If the option is trueHttpProducer will ignore the Exchange.HTTP_URI header, and use the endpoint's URI for request. You may also set throwExceptionOnFailure=false to ensure all responses are propagated back to the  HttpProducer.

From Camel 2.3: when true the HttpProducer and CamelServlet will skip gzip processing when content-encoding=gzip.

disableStreamCache

false

When false the DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body which allows it to be read more than once.

When true the DefaultHttpBinding will set the request input stream direct into the message body.

From Camel 2.17: this options is now also support by the producer to allow using the response stream directly instead of stream caching as by default.

httpBindingRef

null

Deprecated and removed in Camel 2.17: Reference to a org.apache.camel.component.http.HttpBinding in the Registry. Use the httpBinding option instead.

httpBinding

null

From Camel 2.3: reference to a org.apache.camel.component.http.HttpBinding in the Registry.

httpClientConfigurerRef

null

Deprecated and removed in Camel 2.17: Reference to a org.apache.camel.component.http.HttpClientConfigurer in the Registry. Use the httpClientConfigurer option instead.

httpClientConfigurer

null

From Camel 2.3: reference to a org.apache.camel.component.http.HttpClientConfigurer in the Registry.

httpClient.XXX

null

Use this to option to configure the underlying HttpClientParams.

Example: Setting options on the HttpClientParams. For instance httpClient.soTimeout=5000 will set the SO_TIMEOUT to 5 seconds.

clientConnectionManager

null

To use a custom org.apache.http.conn.ClientConnectionManager.

transferException

false

From Camel 2.6: If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or SERVLET Camel components).

On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. The caused exception will be serialized.

headerFilterStrategy

null

From Camel 2.11: reference to a instance of org.apache.camel.spi.HeaderFilterStrategy in the Registry. It will be used to apply the custom headerFilterStrategy on the new create HttpEndpoint.

urlRewrite

null

From Camel 2.11: Producer only!

Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite URLs when you bridge/proxy endpoints.

See more details at UrlRewrite and How to use Camel as a HTTP proxy between a client and server.

eagerCheckContentAvailable

false

From Camel 2.15.3/2.16: Consumer only!

Whether to eager check whether the HTTP requests has content when content-length=0 or is not present.

This option should be set to true for those HTTP clients that do not send streamed data.

copyHeaders

true

From Camel 2.16: if this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy.

Setting this to false, allows to only include the headers from the HTTP response (not propagating IN headers).

okStatusCodeRange

200-299

From Camel 2.16: the range of HTTP status codes for which a response is considered a success. The values are inclusive. The range must be defined as in the form from-to with the , dash included.

ignoreResponseBody

false

From Camel 2.16: when true the HttpProducer will not read the response body nor cache the input stream.

cookieHandler

null

From Camel: 2.19: configure a cookie handler to maintain a HTTP session

...

Configuring charset

If you are using using POST to send data you can configure the charset:

Code Block
.setProperty(Exchange.CHARSET_NAME, "iso-8859-1");

...

Code Block
languagejava
from("timer://foo?fixedRate=true&delay=0&period=10000")
    .to("http://www.google.com")
    .setHeader(FileComponent.HEADER_FILE_NAME, "message.html")
    .to("file:target/google");

...

You can get the HTTP response code from the HTTP component by getting the value from the OUT message header with Exchange.HTTP_RESPONSE_CODE:

Code Block
java
java
   Exchange exchange = template.send("http://www.google.com/search", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(Exchange.HTTP_QUERY, constant("hl=en&q=activemq"));
            }
   });

   Message out = exchange.getOut();
   int responseCode = out.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);

...

To disable cookies you can set the HTTP Client to ignore cookies by adding this URI option:
httpClient.cookiePolicy=ignoreCookies

...

Code Block
languagejava
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);

ProtocolSocketFactory factory =
    new SSLContextParametersSecureProtocolSocketFactory(scp);

Protocol.registerProtocol("https",
        new Protocol(
        "https",
        factory,
        443));

from("direct:start")
        .to("https://mail.google.com/mail/")
    .to("mock:results");
Configuring Apache HTTP Client Directly

...

Code Block
languagejava
Protocol authhttps = new Protocol("https", 
                                  new AuthSSLProtocolSocketFactory(
  new URL("file:my.keystore"), "mypassword",
  new URL("file:my.truststore"), "mypassword"), 
                                  443);

Protocol.registerProtocol("https", authhttps);

...

Code Block
languagexml
<bean id="myHttpClientConfigurer"
 class="my.https.HttpClientConfigurer"/>
</bean>

<to uri="https://myhostname.com:443/myURL?httpClientConfigurerRef=myHttpClientConfigurer"/>

...