You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Fyodor Kravchenko <fe...@vsetec.com> on 2023/10/15 19:16:10 UTC

HttpServletRequest and Platform HTTP

Hello,

in Camel 2 and Jetty I used to get my hands on HttpServletRequest by

             HttpMessage http = exchange.getIn(HttpMessage.class);
             HttpServletRequest request = http.getRequest();

, but now I'm migrating to 4.0.1 and platform-http (currently 
camel-platform-http-main), and now I'm getting null instead of the 
HttpMessage.

Is it related to the note in  the Camel 4 migration guide - " And all 
|HttpMessage| has been changed to generic |Message| types"? What is the 
correct method of getting the raw HttpServletRequest and its internals 
like headers, sessions and cookies, if there is any? Can't find a 
documented way of doing this, for example, by calling 
`HttpServletRequest request = http.getBody(HttpServletRequest.class);`.


Thank you!

-fedd


Re: HttpServletRequest and Platform HTTP

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Oct 18, 2023 at 4:26 PM Fyodor Kravchenko <fe...@vsetec.com> wrote:

> Hi, thank you!
>
> Good that the http headers are abstracted from the actual underlying
> http technology.
>
> What about Cookies? Will getHeader(Exchange.COOKIE_HANDLER) work with
> the Platform Http? Couldn't find if I can specify anything like
> "|?cookieHandler=#exchangeCookieHandler|" in the route url... Or can I
> access and parse the multiple cookie *headers* from the Message?
>
> Accessing the Vert.x objects in Camel 4.2.0 is good, but what if we
> decide to switch platform in the future (again :) Would be nice to have
> a cookie handler or some other session abstraction.
>
>
There is no cookie handler for platform-http. That would require
camel-platform-http-vertx to add support for this.
You are welcome to look into this and if possible create a JIRA and send PR.





> Regards,
>
> Fyodor
>
> On 17.10.2023 10:59, Claus Ibsen wrote:
> > Hi
> >
> > You usually just set the a camel message header with the HTTP key/value
> for
> > redirect, something ala:
> >
> >
> > exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);
> >                          exchange.getMessage().setHeader("location",
> "http
> > url of the redirect location");
> >
> >
> > On Mon, Oct 16, 2023 at 1:17 PM Fyodor Kravchenko <fe...@vsetec.com>
> wrote:
> >
> >> Thank you, Claus, I'll get familiarized myself with the Vert.X
> >> internals! In the meantime, there must be some way to "send redirect"
> >> (respond with the 302 header) by the Camel means, can you please give
> >> some hint on that?
> >>
> >> On 16.10.2023 11:18, Claus Ibsen wrote:
> >>> Hi
> >>>
> >>> I created a ticket
> >>> https://issues.apache.org/jira/browse/CAMEL-19994
> >>>
> >>> Yeah check vertx-http docs what it offers
> >>> https://vertx.io/docs/vertx-web/java/
> >>>
> >>>
> >>>
> >>> On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko <fe...@vsetec.com>
> >> wrote:
> >>>> Hi, thanks, I get that. And without the Vertx object, what would be a
> >>>> correct way to obtain somewhat like a session attributes? I'm having
> >>>> trouble to navigate the documentation and find "vertx-http"
> description,
> >>>> can't get how to see and set, for example, the cookies. There are 3
> >>>> "vertx" entries in the docs, the client, the websocket and some "vertx
> >>>> json eventbus", so I'm sorry to admit I'm a bit lost.
> >>>>
> >>>> in essence I need 2 things: organize some sort of a session with a
> >>>> session state (through cookies or if camel vertx component allows,
> >>>> differently), and be able to read/print raw bytes to/from the web
> >> client.
> >>>> On 16.10.2023 09:33, Claus Ibsen wrote:
> >>>>> Hi
> >>>>>
> >>>>> platform-http-main is based on vertx-http as HTTP server and this is
> >> NOT
> >>>>> servlet based.
> >>>>> But vertx-http has a similar API where you can get access to headers
> /
> >>>>> cookies etc.
> >>>>> However we don't store the "raw vertx object" that makes this easy
> with
> >>>>> Camel.
> >>>>>
> >>>>> This needs to be enhanced in camel-platform-http-vertx.
> >>>>>
> >>>>>
> >>>>> On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com>
> >>>> wrote:
> >>>>>> Hello,
> >>>>>>
> >>>>>> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
> >>>>>>
> >>>>>>                 HttpMessage http =
> exchange.getIn(HttpMessage.class);
> >>>>>>                 HttpServletRequest request = http.getRequest();
> >>>>>>
> >>>>>> , but now I'm migrating to 4.0.1 and platform-http (currently
> >>>>>> camel-platform-http-main), and now I'm getting null instead of the
> >>>>>> HttpMessage.
> >>>>>>
> >>>>>> Is it related to the note in  the Camel 4 migration guide - " And
> all
> >>>>>> |HttpMessage| has been changed to generic |Message| types"? What is
> >> the
> >>>>>> correct method of getting the raw HttpServletRequest and its
> internals
> >>>>>> like headers, sessions and cookies, if there is any? Can't find a
> >>>>>> documented way of doing this, for example, by calling
> >>>>>> `HttpServletRequest request =
> >> http.getBody(HttpServletRequest.class);`.
> >>>>>>
> >>>>>> Thank you!
> >>>>>>
> >>>>>> -fedd
> >>>>>>
> >>>>>>
> >
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: HttpServletRequest and Platform HTTP

Posted by Fyodor Kravchenko <fe...@vsetec.com>.
Hi, thank you!

Good that the http headers are abstracted from the actual underlying 
http technology.

What about Cookies? Will getHeader(Exchange.COOKIE_HANDLER) work with 
the Platform Http? Couldn't find if I can specify anything like 
"|?cookieHandler=#exchangeCookieHandler|" in the route url... Or can I 
access and parse the multiple cookie *headers* from the Message?

Accessing the Vert.x objects in Camel 4.2.0 is good, but what if we 
decide to switch platform in the future (again :) Would be nice to have 
a cookie handler or some other session abstraction.

Regards,

Fyodor

On 17.10.2023 10:59, Claus Ibsen wrote:
> Hi
>
> You usually just set the a camel message header with the HTTP key/value for
> redirect, something ala:
>
>
> exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);
>                          exchange.getMessage().setHeader("location", "http
> url of the redirect location");
>
>
> On Mon, Oct 16, 2023 at 1:17 PM Fyodor Kravchenko <fe...@vsetec.com> wrote:
>
>> Thank you, Claus, I'll get familiarized myself with the Vert.X
>> internals! In the meantime, there must be some way to "send redirect"
>> (respond with the 302 header) by the Camel means, can you please give
>> some hint on that?
>>
>> On 16.10.2023 11:18, Claus Ibsen wrote:
>>> Hi
>>>
>>> I created a ticket
>>> https://issues.apache.org/jira/browse/CAMEL-19994
>>>
>>> Yeah check vertx-http docs what it offers
>>> https://vertx.io/docs/vertx-web/java/
>>>
>>>
>>>
>>> On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko <fe...@vsetec.com>
>> wrote:
>>>> Hi, thanks, I get that. And without the Vertx object, what would be a
>>>> correct way to obtain somewhat like a session attributes? I'm having
>>>> trouble to navigate the documentation and find "vertx-http" description,
>>>> can't get how to see and set, for example, the cookies. There are 3
>>>> "vertx" entries in the docs, the client, the websocket and some "vertx
>>>> json eventbus", so I'm sorry to admit I'm a bit lost.
>>>>
>>>> in essence I need 2 things: organize some sort of a session with a
>>>> session state (through cookies or if camel vertx component allows,
>>>> differently), and be able to read/print raw bytes to/from the web
>> client.
>>>> On 16.10.2023 09:33, Claus Ibsen wrote:
>>>>> Hi
>>>>>
>>>>> platform-http-main is based on vertx-http as HTTP server and this is
>> NOT
>>>>> servlet based.
>>>>> But vertx-http has a similar API where you can get access to headers /
>>>>> cookies etc.
>>>>> However we don't store the "raw vertx object" that makes this easy with
>>>>> Camel.
>>>>>
>>>>> This needs to be enhanced in camel-platform-http-vertx.
>>>>>
>>>>>
>>>>> On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com>
>>>> wrote:
>>>>>> Hello,
>>>>>>
>>>>>> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
>>>>>>
>>>>>>                 HttpMessage http = exchange.getIn(HttpMessage.class);
>>>>>>                 HttpServletRequest request = http.getRequest();
>>>>>>
>>>>>> , but now I'm migrating to 4.0.1 and platform-http (currently
>>>>>> camel-platform-http-main), and now I'm getting null instead of the
>>>>>> HttpMessage.
>>>>>>
>>>>>> Is it related to the note in  the Camel 4 migration guide - " And all
>>>>>> |HttpMessage| has been changed to generic |Message| types"? What is
>> the
>>>>>> correct method of getting the raw HttpServletRequest and its internals
>>>>>> like headers, sessions and cookies, if there is any? Can't find a
>>>>>> documented way of doing this, for example, by calling
>>>>>> `HttpServletRequest request =
>> http.getBody(HttpServletRequest.class);`.
>>>>>>
>>>>>> Thank you!
>>>>>>
>>>>>> -fedd
>>>>>>
>>>>>>
>

Re: HttpServletRequest and Platform HTTP

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You usually just set the a camel message header with the HTTP key/value for
redirect, something ala:


exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);
                        exchange.getMessage().setHeader("location", "http
url of the redirect location");


On Mon, Oct 16, 2023 at 1:17 PM Fyodor Kravchenko <fe...@vsetec.com> wrote:

> Thank you, Claus, I'll get familiarized myself with the Vert.X
> internals! In the meantime, there must be some way to "send redirect"
> (respond with the 302 header) by the Camel means, can you please give
> some hint on that?
>
> On 16.10.2023 11:18, Claus Ibsen wrote:
> > Hi
> >
> > I created a ticket
> > https://issues.apache.org/jira/browse/CAMEL-19994
> >
> > Yeah check vertx-http docs what it offers
> > https://vertx.io/docs/vertx-web/java/
> >
> >
> >
> > On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko <fe...@vsetec.com>
> wrote:
> >
> >> Hi, thanks, I get that. And without the Vertx object, what would be a
> >> correct way to obtain somewhat like a session attributes? I'm having
> >> trouble to navigate the documentation and find "vertx-http" description,
> >> can't get how to see and set, for example, the cookies. There are 3
> >> "vertx" entries in the docs, the client, the websocket and some "vertx
> >> json eventbus", so I'm sorry to admit I'm a bit lost.
> >>
> >> in essence I need 2 things: organize some sort of a session with a
> >> session state (through cookies or if camel vertx component allows,
> >> differently), and be able to read/print raw bytes to/from the web
> client.
> >>
> >> On 16.10.2023 09:33, Claus Ibsen wrote:
> >>> Hi
> >>>
> >>> platform-http-main is based on vertx-http as HTTP server and this is
> NOT
> >>> servlet based.
> >>> But vertx-http has a similar API where you can get access to headers /
> >>> cookies etc.
> >>> However we don't store the "raw vertx object" that makes this easy with
> >>> Camel.
> >>>
> >>> This needs to be enhanced in camel-platform-http-vertx.
> >>>
> >>>
> >>> On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com>
> >> wrote:
> >>>> Hello,
> >>>>
> >>>> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
> >>>>
> >>>>                HttpMessage http = exchange.getIn(HttpMessage.class);
> >>>>                HttpServletRequest request = http.getRequest();
> >>>>
> >>>> , but now I'm migrating to 4.0.1 and platform-http (currently
> >>>> camel-platform-http-main), and now I'm getting null instead of the
> >>>> HttpMessage.
> >>>>
> >>>> Is it related to the note in  the Camel 4 migration guide - " And all
> >>>> |HttpMessage| has been changed to generic |Message| types"? What is
> the
> >>>> correct method of getting the raw HttpServletRequest and its internals
> >>>> like headers, sessions and cookies, if there is any? Can't find a
> >>>> documented way of doing this, for example, by calling
> >>>> `HttpServletRequest request =
> http.getBody(HttpServletRequest.class);`.
> >>>>
> >>>>
> >>>> Thank you!
> >>>>
> >>>> -fedd
> >>>>
> >>>>
> >
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: HttpServletRequest and Platform HTTP

Posted by Fyodor Kravchenko <fe...@vsetec.com>.
Thank you, Claus, I'll get familiarized myself with the Vert.X 
internals! In the meantime, there must be some way to "send redirect" 
(respond with the 302 header) by the Camel means, can you please give 
some hint on that?

On 16.10.2023 11:18, Claus Ibsen wrote:
> Hi
>
> I created a ticket
> https://issues.apache.org/jira/browse/CAMEL-19994
>
> Yeah check vertx-http docs what it offers
> https://vertx.io/docs/vertx-web/java/
>
>
>
> On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko <fe...@vsetec.com> wrote:
>
>> Hi, thanks, I get that. And without the Vertx object, what would be a
>> correct way to obtain somewhat like a session attributes? I'm having
>> trouble to navigate the documentation and find "vertx-http" description,
>> can't get how to see and set, for example, the cookies. There are 3
>> "vertx" entries in the docs, the client, the websocket and some "vertx
>> json eventbus", so I'm sorry to admit I'm a bit lost.
>>
>> in essence I need 2 things: organize some sort of a session with a
>> session state (through cookies or if camel vertx component allows,
>> differently), and be able to read/print raw bytes to/from the web client.
>>
>> On 16.10.2023 09:33, Claus Ibsen wrote:
>>> Hi
>>>
>>> platform-http-main is based on vertx-http as HTTP server and this is NOT
>>> servlet based.
>>> But vertx-http has a similar API where you can get access to headers /
>>> cookies etc.
>>> However we don't store the "raw vertx object" that makes this easy with
>>> Camel.
>>>
>>> This needs to be enhanced in camel-platform-http-vertx.
>>>
>>>
>>> On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com>
>> wrote:
>>>> Hello,
>>>>
>>>> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
>>>>
>>>>                HttpMessage http = exchange.getIn(HttpMessage.class);
>>>>                HttpServletRequest request = http.getRequest();
>>>>
>>>> , but now I'm migrating to 4.0.1 and platform-http (currently
>>>> camel-platform-http-main), and now I'm getting null instead of the
>>>> HttpMessage.
>>>>
>>>> Is it related to the note in  the Camel 4 migration guide - " And all
>>>> |HttpMessage| has been changed to generic |Message| types"? What is the
>>>> correct method of getting the raw HttpServletRequest and its internals
>>>> like headers, sessions and cookies, if there is any? Can't find a
>>>> documented way of doing this, for example, by calling
>>>> `HttpServletRequest request = http.getBody(HttpServletRequest.class);`.
>>>>
>>>>
>>>> Thank you!
>>>>
>>>> -fedd
>>>>
>>>>
>

Re: HttpServletRequest and Platform HTTP

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I created a ticket
https://issues.apache.org/jira/browse/CAMEL-19994

Yeah check vertx-http docs what it offers
https://vertx.io/docs/vertx-web/java/



On Mon, Oct 16, 2023 at 10:12 AM Fyodor Kravchenko <fe...@vsetec.com> wrote:

> Hi, thanks, I get that. And without the Vertx object, what would be a
> correct way to obtain somewhat like a session attributes? I'm having
> trouble to navigate the documentation and find "vertx-http" description,
> can't get how to see and set, for example, the cookies. There are 3
> "vertx" entries in the docs, the client, the websocket and some "vertx
> json eventbus", so I'm sorry to admit I'm a bit lost.
>
> in essence I need 2 things: organize some sort of a session with a
> session state (through cookies or if camel vertx component allows,
> differently), and be able to read/print raw bytes to/from the web client.
>
> On 16.10.2023 09:33, Claus Ibsen wrote:
> > Hi
> >
> > platform-http-main is based on vertx-http as HTTP server and this is NOT
> > servlet based.
> > But vertx-http has a similar API where you can get access to headers /
> > cookies etc.
> > However we don't store the "raw vertx object" that makes this easy with
> > Camel.
> >
> > This needs to be enhanced in camel-platform-http-vertx.
> >
> >
> > On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com>
> wrote:
> >
> >> Hello,
> >>
> >> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
> >>
> >>               HttpMessage http = exchange.getIn(HttpMessage.class);
> >>               HttpServletRequest request = http.getRequest();
> >>
> >> , but now I'm migrating to 4.0.1 and platform-http (currently
> >> camel-platform-http-main), and now I'm getting null instead of the
> >> HttpMessage.
> >>
> >> Is it related to the note in  the Camel 4 migration guide - " And all
> >> |HttpMessage| has been changed to generic |Message| types"? What is the
> >> correct method of getting the raw HttpServletRequest and its internals
> >> like headers, sessions and cookies, if there is any? Can't find a
> >> documented way of doing this, for example, by calling
> >> `HttpServletRequest request = http.getBody(HttpServletRequest.class);`.
> >>
> >>
> >> Thank you!
> >>
> >> -fedd
> >>
> >>
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: HttpServletRequest and Platform HTTP

Posted by Fyodor Kravchenko <fe...@vsetec.com>.
Hi, thanks, I get that. And without the Vertx object, what would be a 
correct way to obtain somewhat like a session attributes? I'm having 
trouble to navigate the documentation and find "vertx-http" description, 
can't get how to see and set, for example, the cookies. There are 3 
"vertx" entries in the docs, the client, the websocket and some "vertx 
json eventbus", so I'm sorry to admit I'm a bit lost.

in essence I need 2 things: organize some sort of a session with a 
session state (through cookies or if camel vertx component allows, 
differently), and be able to read/print raw bytes to/from the web client.

On 16.10.2023 09:33, Claus Ibsen wrote:
> Hi
>
> platform-http-main is based on vertx-http as HTTP server and this is NOT
> servlet based.
> But vertx-http has a similar API where you can get access to headers /
> cookies etc.
> However we don't store the "raw vertx object" that makes this easy with
> Camel.
>
> This needs to be enhanced in camel-platform-http-vertx.
>
>
> On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com> wrote:
>
>> Hello,
>>
>> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
>>
>>               HttpMessage http = exchange.getIn(HttpMessage.class);
>>               HttpServletRequest request = http.getRequest();
>>
>> , but now I'm migrating to 4.0.1 and platform-http (currently
>> camel-platform-http-main), and now I'm getting null instead of the
>> HttpMessage.
>>
>> Is it related to the note in  the Camel 4 migration guide - " And all
>> |HttpMessage| has been changed to generic |Message| types"? What is the
>> correct method of getting the raw HttpServletRequest and its internals
>> like headers, sessions and cookies, if there is any? Can't find a
>> documented way of doing this, for example, by calling
>> `HttpServletRequest request = http.getBody(HttpServletRequest.class);`.
>>
>>
>> Thank you!
>>
>> -fedd
>>
>>

Re: HttpServletRequest and Platform HTTP

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

platform-http-main is based on vertx-http as HTTP server and this is NOT
servlet based.
But vertx-http has a similar API where you can get access to headers /
cookies etc.
However we don't store the "raw vertx object" that makes this easy with
Camel.

This needs to be enhanced in camel-platform-http-vertx.


On Sun, Oct 15, 2023 at 9:17 PM Fyodor Kravchenko <fe...@vsetec.com> wrote:

> Hello,
>
> in Camel 2 and Jetty I used to get my hands on HttpServletRequest by
>
>              HttpMessage http = exchange.getIn(HttpMessage.class);
>              HttpServletRequest request = http.getRequest();
>
> , but now I'm migrating to 4.0.1 and platform-http (currently
> camel-platform-http-main), and now I'm getting null instead of the
> HttpMessage.
>
> Is it related to the note in  the Camel 4 migration guide - " And all
> |HttpMessage| has been changed to generic |Message| types"? What is the
> correct method of getting the raw HttpServletRequest and its internals
> like headers, sessions and cookies, if there is any? Can't find a
> documented way of doing this, for example, by calling
> `HttpServletRequest request = http.getBody(HttpServletRequest.class);`.
>
>
> Thank you!
>
> -fedd
>
>

-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2