ghttp Component

The ghttp component contributes to the Camel Components for Google App Engine (GAE). It provides connectivity to the GAE URL fetch service but can also be used to receive messages from servlets (the only way to receive HTTP requests on GAE). This is achieved by extending the Servlet component. As a consequence, ghttp URI formats and options sets differ on the consumer-side (from) and producer-side (to).

URI format

ConsumerSee also Servlet component
ProducerSee also Http component


Name Default Value Context Description
bridgeEndpoint true Producer If set to true the Exchange.HTTP_URI header will be ignored. To override the default endpoint URI with the Exchange.HTTP_URI header set this option to false.
throwExceptionOnFailure true Producer Throw a org.apache.camel.component.gae.http if the response code is >= 400. To disable throwing an exception set this option to false.
inboundBindingRef reference to GHttpBinding Consumer Reference to an InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> in the Registry for customizing the binding of an Exchange to the Servlet API. The referenced binding is used as post-processor to org.apache.camel.component.http.HttpBinding.
outboundBindingRef reference to GHttpBinding Producer Reference to an OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> in the Registry for customizing the binding of an Exchange to the URLFetchService.

On the consumer-side, all options of the Servlet component are supported.

Message headers

On the producer-side the following headers of the Http component are supported.

Name Type Description
Exchange.CONTENT_TYPE String The HTTP content type. Is set on both the in and out message to provide a content type, such as text/html.
Exchange.CONTENT_ENCODING String The HTTP content encoding. Is set on both the in and out message to provide a content encoding, such as gzip.
Exchange.HTTP_METHOD String The HTTP method to execute. One of GET, POST, PUT and DELETE. If not set, POST will be used if the message body is not null, GET otherwise.
Exchange.HTTP_QUERY String Overrides the query part of the endpoint URI or the the query part of Exchange.HTTP_URI (if defined). The query string must be in decoded form.
Exchange.HTTP_URI String Overrides the default endpoint URI if the bridgeEndpoint option is set to false. The URI string must be in decoded form.
Exchange.RESPONSE_CODE int The HTTP response code from URL fetch service responses.

On the consumer-side all headers of the Servlet component component are supported.

Message body

On the producer side the in message body is converted to a byte[]. The out message body is made available as InputStream. If the reponse size exceeds 1 megabyte a ResponseTooLargeException is thrown by the URL fetch service (see quotas and limits).


Receiving messages

For receiving messages via the ghttp component, a CamelHttpTransportServlet must be configured and mapped in the application's web.xml. For example, to handle requests targeted at http://<appname>* or http://localhost/camel/* (when using a local development server) the following servlet mapping must be defined:


Endpoint URI path definitions are relative to this servlet mapping e.g. the route


processes requests targeted at http://<appname> In this example, the request body is ignored and the response body is set to Hello. Requests targeted at http://<appname>* are not processed by default. This requires setting the option matchOnUriPrefix to true.


Sending messages

For sending resquests to external HTTP services the ghttp component uses the URL fetch service. For example, the Camel homepage can the retrieved with the following endpoint definition on the producer-side.


The HTTP method used depends on the Exchange.HTTP_METHOD message header or on the presence of an in-message body (GET if null, POST otherwise). Retrieving the Camel homepage via a GAE application is as simple as


Sending a GET request to http://<appname> returns the Camel homepage. HTTPS-based communication with external services can be enabled with the ghttps scheme.



Maven users will need to add the following dependency to their pom.xml.


where ${camel-version} must be replaced by the actual version of Camel (2.1.0 or higher).

See Also

© 2004-2011 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram