## Name

GHTTP — provides connectivity to the GAE URL fetch service but can also be used to receive messages from servlets

## Overview

The `ghttp` component provides connectivity to the GAE URL fetch service but can also be used to receive messages from servlets. 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

GHTTP endpoints can use the following URI formates:

Format | Context | Comment
--- | --- | ---
`ghttp:///`path`[?`options`]` | Consumer | See also Servlet component
`ghttp://`hostname`[:`port`][/`path`][?`options`]` | Producer | See also HTTP
`ghttps://`hostname`[:`port`][/`path`][?`options`]` | Producer | See also HTTP

## Dependencies

Maven users will need to add a dependency on `camel-gae` to their poms as shown in Example 6, “GHTTP dependency”.

Example 6. GHTTP dependency

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-gae</artifactId>
        <version>x.x.x</version>
        <!-- use the same version as your Camel core version -->
    </dependency>

## Options

Table 17, “GHTTP options” lists the options for a GHTTP endpoint.

Table 17. GHTTP options

Name | Default | Context | Description
--- | --- | --- | ---
`bridgeEndpoint` | `true` | Producer | Specifies if the `Exchange.HTTP_URI` header is ignored.
`throwExceptionOnFailure` | `true` | Producer | Specifies if a `org.apache.camel.component.gae.http` is thrown when the response code is >= 400.
`inboundBindingRef` |  | Consumer | Specifies a 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` |  | Producer | Specifies a reference to an `InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse>` in the registry for customizing the binding of an exchange to the `URLFetchService`.

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

## Message headers

On the producer side, the following headers of the HTTP endpoint are supported.

Name | Type | Description
--- | --- | ---
`Content-Type` | `String` | Specifies the HTTP content type. This header is populated on both the IN and OUT message to provide a content type.
`Content-Encoding` | `String` | Specifies the HTTP content encoding. This header is populated on both the IN and OUT message to provide a content encoding.
`CamelHttpMethod` | `String` | Specifies the HTTP method to execute. Can be one of `GET`, `POST`, `PUT` or `DELETE`. If not set, `POST` will be used if the message body is not `null`, `GET` otherwise.
`CamelHttpQuery` | `String` | Overrides the query part of the endpoint URI or `HTTP_URI`. The query string must be in decoded form.
`CamelHttpUri` | `String` | Overrides the default endpoint URI if the `bridgeEndpoint` option is set to `false`. The URI string must be in decoded form.
`CamelHttpResponseCode` | `int` | Specifies the HTTP response code from URL fetch service responses.

On the consumer-side all headers of the Servlet component headers 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).

## Related topics

HTTP
Servlet
GAE URL fetch service