camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <>
Subject [jira] [Updated] (CAMEL-8370) CamelHttpResponseCode missing from documentation
Date Wed, 18 Feb 2015 06:39:11 GMT


Claus Ibsen updated CAMEL-8370:
    Labels:   (was: documentation)

> CamelHttpResponseCode missing from documentation
> ------------------------------------------------
>                 Key: CAMEL-8370
>                 URL:
>             Project: Camel
>          Issue Type: Task
>          Components: documentation
>    Affects Versions: 2.14.1
>            Reporter: Mark Mindenhall
>            Priority: Minor
> I sent the following to the list earlier today:
> {quote}
> I’m using the camel-netty4-http (latest 2.14.2-SNAPSHOT) component to create an endpoint
that receives an HTTP POST from a device, translates the message from binary to JSON, then
sends it along to a kafka topic for further processing.  When there are errors in validating
or translating the incoming message, I need to be able to return a HTTP response code and
response body.
> The camel-netty4-http documentation has an “Access to Netty types” section, which
says that I should be able to do the following to access the instance of io.netty.handler.codec.http.HttpResponse:
>     HttpResponse response = exchange.getIn(NettyHttpMessage.class).getHttpResponse();
> Regardless of where I access the exchange within the route, getHttpResponse() is always
returning null.  On the "happy path” I can return 200 by calling exchange.getOut().setBody(myResponse),
but I have been unable to figure out how to return another response code.
> Is this a bug?  Or is there another way to accomplish what I’m trying to do?
> {quote}
> After digging around in the code, it looks like the HTTP status code is set via the CamelHttpResponseCode
message header (org.apache.camel.component.netty4.http.DefaultNettyHttpBinding, line 308).
 However, there is no mention of this message header in either the camel-netty-http or camel-netty4-http
documentation.  It would be helpful to add this header to the list of applicable message headers,
and also to include an example that demonstrates how to set the response status code and body:
> Finally, the existing "Access to Netty types" example should be modified to be clear
that only the request can be accessed in this way.
> {code}
> // specify response body and status
> exchange.getOut().setBody(myResponseBody);               exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE,
> {code}

This message was sent by Atlassian JIRA

View raw message