camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: svn commit: r907978 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ components/camel-http/src/main/java/org/apache/camel/component/http/
Date Wed, 10 Feb 2010 06:57:28 GMT
Hi Willem

I noticed you did NOT add an unit test to this commit about the
HttpServletRequest/Response stored as IN headers.
Could you please add unit tests for that.

We are planning to do some major upgrades on camel-http and
camel-jetty in 2.3 timeframe.
eg upgrading to http client 4.0.x and jetty 7.x and hence we should
have all features unit tests so we know its still works.



On Tue, Feb 9, 2010 at 11:04 AM, Willem Jiang <willem.jiang@gmail.com> wrote:
> Hi Claus,
>
> I didn't realized the change of HttpConverter introduced the conflicts of
> the Message --> InputStream,
>
> I will revert these part of the HttpConverter change, but I'd like to keep
> the other part of the change, as user can get the HttpServletRequest and
> HttpServletResponse from the message that copy from the HttpMessage, and we
> don't need to change the JIRA.
>
> In Camel 1.x we the HttpMessage can override the message copy and create
> method so the Camel pipeline can preserve the HttpMessage as far as it can.
> But it introduce other problem, we need to keep an eye on message customer
> copy and it also introduced lots of other error which is hard to find out.
>
> Willem
>
> Claus Ibsen wrote:
>>
>> Hi
>>
>> I am not totally happy about this. You may end with a type converter
>> duplicate when you do a Message -> InputStream as an existing type
>> converter may exists.
>>
>> I would like to -1 this ticket in the 2.x timeframe.
>>
>> The issue is that we have specialized xxxMessage objects where it may
>> be better to not have that at all and store message specific stuff in
>> another way.
>> The Camel pipeline will preserve the HttpMessage along the way until
>> you hit another specialized message such as JmsMessage etc.
>>
>> So willem do you mind doing a revert on this one and set the ticket to
>> FUTURE.
>>
>>
>> On Tue, Feb 9, 2010 at 10:06 AM,  <ningjiang@apache.org> wrote:
>>>
>>> Author: ningjiang
>>> Date: Tue Feb  9 09:06:51 2010
>>> New Revision: 907978
>>>
>>> URL: http://svn.apache.org/viewvc?rev=907978&view=rev
>>> Log:
>>> CAMEL-2453 put the HttpServletRequest and HttpServletResponse into
>>> HttpMessage header.
>>>
>>> Modified:
>>>   camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
>>>
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
>>>
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
>>>
>>> Modified:
>>> camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
>>> URL:
>>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=907978&r1=907977&r2=907978&view=diff
>>>
>>> ==============================================================================
>>> --- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
>>> (original)
>>> +++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
>>> Tue Feb  9 09:06:51 2010
>>> @@ -116,6 +116,9 @@
>>>    String TRACE_EVENT_EXCHANGE  = "CamelTraceEventExchange";
>>>
>>>    String SOAP_ACTION = "CamelSoapAction";
>>> +
>>> +    String HTTP_SERVLET_REQUEST = "CamelHttpServletRequest";
>>> +    String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse";
>>>
>>>    /**
>>>     * Returns the {@link ExchangePattern} (MEP) of this exchange.
>>>
>>> Modified:
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
>>> URL:
>>> http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java?rev=907978&r1=907977&r2=907978&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
>>> (original)
>>> +++
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
>>> Tue Feb  9 09:06:51 2010
>>> @@ -19,12 +19,14 @@
>>>  import java.io.BufferedReader;
>>>  import java.io.IOException;
>>>  import java.io.InputStream;
>>> +
>>>  import javax.servlet.ServletInputStream;
>>>  import javax.servlet.http.HttpServletRequest;
>>>  import javax.servlet.http.HttpServletResponse;
>>>
>>>  import org.apache.camel.Converter;
>>>  import org.apache.camel.Exchange;
>>> +import org.apache.camel.Message;
>>>  import org.apache.camel.component.http.helper.GZIPHelper;
>>>
>>>  /**
>>> @@ -40,23 +42,25 @@
>>>    }
>>>
>>>    @Converter
>>> -    public static HttpServletRequest toServletRequest(HttpMessage
>>> message) {
>>> +    public static HttpServletRequest toServletRequest(Message message) {
>>>        if (message == null) {
>>>            return null;
>>>        }
>>> -        return message.getRequest();
>>> +        return message.getHeader(Exchange.HTTP_SERVLET_REQUEST,
>>> HttpServletRequest.class);
>>>    }
>>>
>>>    @Converter
>>> -    public static HttpServletResponse toServletResponse(HttpMessage
>>> message) {
>>> +    public static HttpServletResponse toServletResponse(Message message)
>>> {
>>>        if (message == null) {
>>>            return null;
>>>        }
>>> -        return message.getResponse();
>>> +        return message.getHeader(Exchange.HTTP_SERVLET_RESPONSE,
>>> HttpServletResponse.class);
>>>    }
>>> +
>>> +
>>>
>>>    @Converter
>>> -    public static ServletInputStream toServletInputStream(HttpMessage
>>> message) throws IOException {
>>> +    public static ServletInputStream toServletInputStream(Message
>>> message) throws IOException {
>>>        HttpServletRequest request = toServletRequest(message);
>>>        if (request != null) {
>>>            return request.getInputStream();
>>> @@ -65,12 +69,12 @@
>>>    }
>>>
>>>    @Converter
>>> -    public static InputStream toInputStream(HttpMessage message) throws
>>> Exception {
>>> +    public static InputStream toInputStream(Message message) throws
>>> Exception {
>>>        return toInputStream(toServletRequest(message));
>>>    }
>>>
>>>    @Converter
>>> -    public static BufferedReader toReader(HttpMessage message) throws
>>> IOException {
>>> +    public static BufferedReader toReader(Message message) throws
>>> IOException {
>>>        HttpServletRequest request = toServletRequest(message);
>>>        if (request != null) {
>>>            return request.getReader();
>>>
>>> Modified:
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
>>> URL:
>>> http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java?rev=907978&r1=907977&r2=907978&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
>>> (original)
>>> +++
>>> camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
>>> Tue Feb  9 09:06:51 2010
>>> @@ -37,6 +37,9 @@
>>>        setExchange(exchange);
>>>        this.request = request;
>>>        this.response = response;
>>> +        // Put the request and response into the message header
>>> +        this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
>>> +        this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
>>>
>>>        // use binding to read the request allowing end users to use their
>>>        // implementation of the binding
>>>
>>>
>>>
>>
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message