You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Trevv <45...@safe-mail.net> on 2008/11/25 09:30:06 UTC

Re: HttpProducer: how to access the body of an error page?


Claus Ibsen-2 wrote:
> The patch at http://issues.apache.org/activemq/browse/CAMEL-1083 might
> give some points for sending a HTTP request to HTTP server that
> returns a error code 500 so it triggers the
> HttpOperationFailedException.
Thank you Claus, your patch almost restores the 1.4.0 functionality
that I need.

Now I can access the error page content, as a stream of raw bytes.
But I can't convert those raw bytes into something more meaningful
(e.g. characters) because the Content-Type header has been discarded.
-- 
View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20676965.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: HttpProducer: how to access the body of an error page?

Posted by Trevv <45...@safe-mail.net>.

Claus Ibsen-2 wrote:
> 
> If anyone knows if HttpClient will consider contenttype charset when
> you use it's method to get the response body as a String, then we
> could use this one and expose it on the HttpOperationFailedException
> as well so you can use this instead of dealing with the charset
> convertions yourself
Yes, org.apache.commons.httpclient.HttpMethod.getResponseBodyAsString()
does work that way, and it probably would be helpful for some future
camel riders, though I don't personally need that feature for my
current application.
-- 
View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20699379.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: HttpProducer: how to access the body of an error page?

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

If anyone knows if HttpClient will consider contenttype charset when
you use it's method to get the response body as a String, then we
could use this one and expose it on the HttpOperationFailedException
as well so you can use this instead of dealing with the charset
convertions yourself

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/



On Tue, Nov 25, 2008 at 11:40 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Tue, Nov 25, 2008 at 11:34 AM, Trevv <45...@safe-mail.net> wrote:
>>
>>
>> Claus Ibsen-2 wrote:
>>> Ah that would be nice to have the content type on the
>>> HttpOperationException as well?
>>>
>>> But I guess in 99% converting to String would be fine as most servers
>>> return a text/plain or text/html error page.
>> Yes, but to convert bytes to String, you need to know the charset.
>>
>> The charset that was used by the Web server to encode the error page
>> content might not be the same as your camel's JVM's default charset.
> Yeah but that must be on the content type header right?
> text/xml;charset=utf-8 or how this is normally specified?
>
>>
>> Do you mind adding a JIRA ticket to add a getter on the
>>> HttpOperationException for the content type.
>> As an addition to CAMEL-1083, or as a completely new issue?
> A new issue linking to 1083 would be good.
>
>> --
>> View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20678642.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>

Re: HttpProducer: how to access the body of an error page?

Posted by Trevv <45...@safe-mail.net>.

Claus Ibsen-2 wrote:
> Yeah but that must be on the content type header right?
Yes, that's right.  I mis-parsed your earlier message; I thought you
were suggesting that I should convert the byte stream to String without
using the Content-Type header.

text/xml;charset=utf-8 or how this is normally specified?
Yes, that's right.

A new issue linking to 1083 would be good.
See  https://issues.apache.org/activemq/browse/CAMEL-1119 CAMEL-1119 .
-- 
View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20699130.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: HttpProducer: how to access the body of an error page?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Nov 25, 2008 at 11:34 AM, Trevv <45...@safe-mail.net> wrote:
>
>
> Claus Ibsen-2 wrote:
>> Ah that would be nice to have the content type on the
>> HttpOperationException as well?
>>
>> But I guess in 99% converting to String would be fine as most servers
>> return a text/plain or text/html error page.
> Yes, but to convert bytes to String, you need to know the charset.
>
> The charset that was used by the Web server to encode the error page
> content might not be the same as your camel's JVM's default charset.
Yeah but that must be on the content type header right?
text/xml;charset=utf-8 or how this is normally specified?

>
> Do you mind adding a JIRA ticket to add a getter on the
>> HttpOperationException for the content type.
> As an addition to CAMEL-1083, or as a completely new issue?
A new issue linking to 1083 would be good.

> --
> View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20678642.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: HttpProducer: how to access the body of an error page?

Posted by Trevv <45...@safe-mail.net>.

Claus Ibsen-2 wrote:
> Ah that would be nice to have the content type on the
> HttpOperationException as well?
> 
> But I guess in 99% converting to String would be fine as most servers
> return a text/plain or text/html error page.
Yes, but to convert bytes to String, you need to know the charset.

The charset that was used by the Web server to encode the error page
content might not be the same as your camel's JVM's default charset.

Do you mind adding a JIRA ticket to add a getter on the
> HttpOperationException for the content type.
As an addition to CAMEL-1083, or as a completely new issue?
-- 
View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20678642.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: HttpProducer: how to access the body of an error page?

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

Ah that would be nice to have the content type on the
HttpOperationException as well?

But I guess in 99% converting to String would be fine as most servers
return a text/plain or text/html error page.
Do you mind adding a JIRA ticket to add a getter on the
HttpOperationException for the content type.



/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/



On Tue, Nov 25, 2008 at 9:30 AM, Trevv <45...@safe-mail.net> wrote:
>
>
> Claus Ibsen-2 wrote:
>> The patch at http://issues.apache.org/activemq/browse/CAMEL-1083 might
>> give some points for sending a HTTP request to HTTP server that
>> returns a error code 500 so it triggers the
>> HttpOperationFailedException.
> Thank you Claus, your patch almost restores the 1.4.0 functionality
> that I need.
>
> Now I can access the error page content, as a stream of raw bytes.
> But I can't convert those raw bytes into something more meaningful
> (e.g. characters) because the Content-Type header has been discarded.
> --
> View this message in context: http://www.nabble.com/HttpProducer%3A-how-to-access-the-body-of-an-error-page--tp20475651s22882p20676965.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>