You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2022/03/29 08:56:00 UTC
[jira] [Resolved] (CAMEL-17870) Null value for HttpServletRequest after http call
[ https://issues.apache.org/jira/browse/CAMEL-17870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-17870.
---------------------------------
Resolution: Not A Bug
That doc page is wrong I am removing that section.
> Null value for HttpServletRequest after http call
> -------------------------------------------------
>
> Key: CAMEL-17870
> URL: https://issues.apache.org/jira/browse/CAMEL-17870
> Project: Camel
> Issue Type: Bug
> Components: camel-http
> Affects Versions: 3.16.0
> Reporter: Andy Mitchell
> Priority: Minor
>
> I am trying to generate an audit message after a HTTP call, the audit message needs to contain the body of the original request.
>
> I have the following route snippet:
>
> {{{}from("direct:myqueue"){}}}{{{}.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST)){}}}{{{}.setHeader(Exchange.CONTENT_TYPE, simple("application/json")){}}}{{{}.to("http://127.0.0.1:4000/"){}}}{{{}.process("AuditProcessor"){}}}{{{}.to("file://target/audit");{}}}
>
> The {{AuditProcessor class contains the fragment:}}
> {{public void process(Exchange exchange) throws Exception {}}
> {{HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);}}
> {{String httpRequestBody = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));}}
>
> however, request is always being evaluated as null.
>
> The documentation [https://camel.apache.org/components/3.15.x/http-component.html#:~:text=camel%2Dcxf%20endpoint.-,HttpServletRequest,-request%20%3D%20exchange.getIn] suggests I should be able to access the request object after the http request in the pipeline.
>
> Thanks
--
This message was sent by Atlassian Jira
(v8.20.1#820001)