How to return a custom HTTP 401/500 reply message?
Issue
- Camel Routes not handling unauthorized http response code (401) properly
- How to return a custom HTTP 401/500 reply message
<route id="true" id="xxx-4443">
<from uri="jetty-clientAuth:https://0.0.0.0:11111/xxx?matchOnUriPrefix=true"/>
<to uri="reqProcessor" id="to2"/>
<to uri="authProcessor" id="to3"/>
<to uri="http://xxx-yyy-zzzz:000/xxx?throwExceptionOnFailure=false&bridgeEndpoint=true" id="to4"/>
</route>
-
In above route's
authProcessorwe are doing some cert validation and based on the validation response if validation fails we are setting up header valueExchange.HTTP_RESPONSE_CODEto "401" and in exchange body message toUnauthorized. -
But when request flows to next part of the route which is
<to uri="http://xxx-yyy-zzzz:000/xxx?throwExceptionOnFailure=false&bridgeEndpoint=true" id="to4"/>, in the client side response header we see http-status code: 500 instead of 401. -
So my question is, could you please let us know how can we set the
unauthorizedcode to 401 in such a way that client could receive correct http status code the header.
Environment
- Red Hat JBoss Fuse
- 6.2.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
