Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Copy edits

...

Code Block
http:hostname[:port][/resourceUri][?options]

Will by default use port 80 for http HTTP and 443 for httpsHTTPS.

You can append query options to the URI in the following format, ?option=value&option=value&...

Info
titlecamel-http vs camel-jetty

You can only produce to endpoints generated by the HTTP component. Therefore it should never be used as input into your camel Routes. To bind/expose an HTTP endpoint via a http HTTP server as input to a camel route, you can use the Jetty Component

...

Name

Default Value

Description

throwExceptionOnFailure

true

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

httpBindingRef

null

Reference to a org.apache.camel.component.http.HttpBinding in the Registry.

username

null

Username for basic http authenticationBasic HTTP Authentication.

password

null

Password for basic http authenticationBasic HTTP Authentication.

proxyHost

null

The proxy host name * only for >= Camel 1.6.2 *.

proxyPort

null

The proxy port number * only for >= Camel 1.6.2 *.

proxyUsername

null

Username for proxy authentication * only for >= Camel 1.6.2 *.

proxyPassword

null

Password for proxy authentication * only for >= Camel 1.6.2 *.

httpClientConfigurerRef

null

Reference to a org.apache.camel.component.http.HttpClientConfigurer in the Registry.

httpClient.XXX

null

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

Message Headers

Camel 1.x

Name

Type

Description

HttpProducer.HTTP_URI

String

Camel 1.5.1: URI to call. Will override existing URI set directly on the endpoint. Is set on the IN In message.

HttpProducer.HTTP_RESPONSE_CODE

int

The http HTTP response code from the external server. Is 200 for OK. Is set on the OUT Out message.

HttpProducer.QUERY

String

URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN In message.

Camel 2.0

Name

Type

Description

Exchange.HTTP_URI

String

URI to call. Will override existing URI set directly on the endpoint. Is set on the IN In message.

Exchange.HTTP_PATH

String

Request URI's path. Is set on the IN In message.

Exchange.HTTP_QUERY

String

URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN In message.

Exchange.HTTP_CHARACTER_ENCODING

String

Character encoding. Is set on the IN In message.

Exchange.HTTP_CONTENT_TYPE

String

Content type. Is set on the IN In message.

Exchange.HTTP_RESPONSE_CODE

int

The http HTTP response code from the external server. Is 200 for OK. Is set on the OUT Out message.

NOTE from Camel 2.0m2, we move the message headers' constants from HttpConstants to Exchange.

Message Body

Camel will store the http HTTP response from the external server on the OUT Out body. All headers from the IN In message will be copied to the OUT Out message, so headers is are preserved during routing.
Additionally Camel will add the http HTTP response headers as well to the OUT Out message.

Response code

Camel will handle according to the http HTTP response code:

  • response Response code is between in the range 100..299 then , Camel regard regards it as a success response.
  • response Response code is between in the range 300..399 then , Camel regard regards it as a redirection was returned response and will throw a HttpOperationFailedException with the information.
  • response Response code is 400+ then , Camel regard regards it as a an external server failure and will throw a HttpOperationFailedException with the information.
    Tip
    titlethrowExceptionOnFailure

    The option, throwExceptionOnFailure, can be set to false to prevent the HttpOperationFailedException to be from being thrown for failed response codes. This allows you to get any response from the remote server.
    There is a sample below demonstrating this.

...

This exception contains the following information:

  • the http The HTTP status code
  • the http The HTTP status line (text of the status code)
  • redirect Redirect location, if server returned a redirect
  • responseBody Response body as a java.io.InputStream, if server provided a body as response

...