You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bee1000 <ri...@hotmail.com> on 2010/04/09 22:19:11 UTC
Restlet url encoding post data?
I'm trying to post documents to couchdb using restlet but the restlet
component is hard coded to url encode the post data. This makes the JSON
text i'm posting invalid. Do I need to use some other component or is there
a way around this?
--
View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28197024.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Restlet url encoding post data?
Posted by William Tam <em...@gmail.com>.
I guess we do not have to use Form object. If using String yields a
more generic solution, we probably should do it. I am comparing the
response message which calls the setEntity() with a String and we can
specify the media type. The headers are set as attributes in the
Restlet message.
Bee1000 wrote:
> I'm working on a patch for this. I have a question. The Camel binding layer
> appears to be mapping non Restlet message headers into URL parameters via
> the Restlet Form object. I believe URL parameters are only valid for GET
> and POST w/content type of application/x-www-form-urlencoded. What should
> we do with the headers for PUT, DELETE, and non-form POSTs?
>
> Should I move this thread to the developers forum? I wasn't sure if only
> jira stuff went there.
>
>
>
> William Tam wrote:
>
>> I see. The method probably should have called request.setEntity(Sting,
>> MediaType) similar to the response message. I'm looking forward to your
>> patch.
>>
>> Thanks,
>> William
>>
>> Bee1000 wrote:
>>
>>> You can set the header, but it is not used in the code. The method calls
>>> form.getWebRepresentation() which is hard coded to use
>>> 'application/x-www-form-urlencoded'.
>>>
>>> I will look into creating a jira issue and a test case, and possibly
>>> provide
>>> a fix as well.
>>>
>>> Rich
>>>
>>>
>>> William Tam wrote:
>>>
>>>
>>>> Have you tried setting the Content-Type header (to "application/json")
>>>> in your request Camel message? It looks like
>>>> DefaultRestletBinding.populateRestletRequestFromExchange() method will
>>>> add the header to the Form. If it does not work, any chance you are
>>>> create a Jira with a testcase? A patch would be great, too. :-)
>>>>
>>>> Bee1000 wrote:
>>>>
>>>>
>>>>> Using http does work, but it still seems like a bug to hard code the
>>>>> encoding
>>>>> of post data for restlet. I thought post data could be any text or
>>>>> binary
>>>>> data. It seems like this reduces the usefulness of the restlet camel
>>>>> component. Just out of curiosity, is there another reason why the
>>>>> encoding
>>>>> is hardcoded? (Perhaps to be more precise, the message body is being
>>>>> encoded in the RESTLET component, which for POST means that post data
>>>>> is
>>>>> being encoded.)
>>>>>
>>>>>
>>>>>
>>>>> willem.jiang wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I think you can try to use Camel-Http component, which is leverage
>>>>>> common http client to invoke the http service.
>>>>>>
>>>>>> Willem
>>>>>>
>>>>>> Bee1000 wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I'm trying to post documents to couchdb using restlet but the restlet
>>>>>>> component is hard coded to url encode the post data. This makes the
>>>>>>> JSON
>>>>>>> text i'm posting invalid. Do I need to use some other component or
>>>>>>> is
>>>>>>> there
>>>>>>> a way around this?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
Re: Restlet url encoding post data?
Posted by Bee1000 <ri...@hotmail.com>.
I'm working on a patch for this. I have a question. The Camel binding layer
appears to be mapping non Restlet message headers into URL parameters via
the Restlet Form object. I believe URL parameters are only valid for GET
and POST w/content type of application/x-www-form-urlencoded. What should
we do with the headers for PUT, DELETE, and non-form POSTs?
Should I move this thread to the developers forum? I wasn't sure if only
jira stuff went there.
William Tam wrote:
>
> I see. The method probably should have called request.setEntity(Sting,
> MediaType) similar to the response message. I'm looking forward to your
> patch.
>
> Thanks,
> William
>
> Bee1000 wrote:
>> You can set the header, but it is not used in the code. The method calls
>> form.getWebRepresentation() which is hard coded to use
>> 'application/x-www-form-urlencoded'.
>>
>> I will look into creating a jira issue and a test case, and possibly
>> provide
>> a fix as well.
>>
>> Rich
>>
>>
>> William Tam wrote:
>>
>>> Have you tried setting the Content-Type header (to "application/json")
>>> in your request Camel message? It looks like
>>> DefaultRestletBinding.populateRestletRequestFromExchange() method will
>>> add the header to the Form. If it does not work, any chance you are
>>> create a Jira with a testcase? A patch would be great, too. :-)
>>>
>>> Bee1000 wrote:
>>>
>>>> Using http does work, but it still seems like a bug to hard code the
>>>> encoding
>>>> of post data for restlet. I thought post data could be any text or
>>>> binary
>>>> data. It seems like this reduces the usefulness of the restlet camel
>>>> component. Just out of curiosity, is there another reason why the
>>>> encoding
>>>> is hardcoded? (Perhaps to be more precise, the message body is being
>>>> encoded in the RESTLET component, which for POST means that post data
>>>> is
>>>> being encoded.)
>>>>
>>>>
>>>>
>>>> willem.jiang wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I think you can try to use Camel-Http component, which is leverage
>>>>> common http client to invoke the http service.
>>>>>
>>>>> Willem
>>>>>
>>>>> Bee1000 wrote:
>>>>>
>>>>>
>>>>>> I'm trying to post documents to couchdb using restlet but the restlet
>>>>>> component is hard coded to url encode the post data. This makes the
>>>>>> JSON
>>>>>> text i'm posting invalid. Do I need to use some other component or
>>>>>> is
>>>>>> there
>>>>>> a way around this?
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28257057.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Restlet url encoding post data?
Posted by William Tam <em...@gmail.com>.
I see. The method probably should have called request.setEntity(Sting,
MediaType) similar to the response message. I'm looking forward to your
patch.
Thanks,
William
Bee1000 wrote:
> You can set the header, but it is not used in the code. The method calls
> form.getWebRepresentation() which is hard coded to use
> 'application/x-www-form-urlencoded'.
>
> I will look into creating a jira issue and a test case, and possibly provide
> a fix as well.
>
> Rich
>
>
> William Tam wrote:
>
>> Have you tried setting the Content-Type header (to "application/json")
>> in your request Camel message? It looks like
>> DefaultRestletBinding.populateRestletRequestFromExchange() method will
>> add the header to the Form. If it does not work, any chance you are
>> create a Jira with a testcase? A patch would be great, too. :-)
>>
>> Bee1000 wrote:
>>
>>> Using http does work, but it still seems like a bug to hard code the
>>> encoding
>>> of post data for restlet. I thought post data could be any text or
>>> binary
>>> data. It seems like this reduces the usefulness of the restlet camel
>>> component. Just out of curiosity, is there another reason why the
>>> encoding
>>> is hardcoded? (Perhaps to be more precise, the message body is being
>>> encoded in the RESTLET component, which for POST means that post data is
>>> being encoded.)
>>>
>>>
>>>
>>> willem.jiang wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> I think you can try to use Camel-Http component, which is leverage
>>>> common http client to invoke the http service.
>>>>
>>>> Willem
>>>>
>>>> Bee1000 wrote:
>>>>
>>>>
>>>>> I'm trying to post documents to couchdb using restlet but the restlet
>>>>> component is hard coded to url encode the post data. This makes the
>>>>> JSON
>>>>> text i'm posting invalid. Do I need to use some other component or is
>>>>> there
>>>>> a way around this?
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
Re: Restlet url encoding post data?
Posted by Bee1000 <ri...@hotmail.com>.
You can set the header, but it is not used in the code. The method calls
form.getWebRepresentation() which is hard coded to use
'application/x-www-form-urlencoded'.
I will look into creating a jira issue and a test case, and possibly provide
a fix as well.
Rich
William Tam wrote:
>
> Have you tried setting the Content-Type header (to "application/json")
> in your request Camel message? It looks like
> DefaultRestletBinding.populateRestletRequestFromExchange() method will
> add the header to the Form. If it does not work, any chance you are
> create a Jira with a testcase? A patch would be great, too. :-)
>
> Bee1000 wrote:
>> Using http does work, but it still seems like a bug to hard code the
>> encoding
>> of post data for restlet. I thought post data could be any text or
>> binary
>> data. It seems like this reduces the usefulness of the restlet camel
>> component. Just out of curiosity, is there another reason why the
>> encoding
>> is hardcoded? (Perhaps to be more precise, the message body is being
>> encoded in the RESTLET component, which for POST means that post data is
>> being encoded.)
>>
>>
>>
>> willem.jiang wrote:
>>
>>> Hi,
>>>
>>> I think you can try to use Camel-Http component, which is leverage
>>> common http client to invoke the http service.
>>>
>>> Willem
>>>
>>> Bee1000 wrote:
>>>
>>>> I'm trying to post documents to couchdb using restlet but the restlet
>>>> component is hard coded to url encode the post data. This makes the
>>>> JSON
>>>> text i'm posting invalid. Do I need to use some other component or is
>>>> there
>>>> a way around this?
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28218645.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Restlet url encoding post data?
Posted by William Tam <em...@gmail.com>.
Have you tried setting the Content-Type header (to "application/json")
in your request Camel message? It looks like
DefaultRestletBinding.populateRestletRequestFromExchange() method will
add the header to the Form. If it does not work, any chance you are
create a Jira with a testcase? A patch would be great, too. :-)
Bee1000 wrote:
> Using http does work, but it still seems like a bug to hard code the encoding
> of post data for restlet. I thought post data could be any text or binary
> data. It seems like this reduces the usefulness of the restlet camel
> component. Just out of curiosity, is there another reason why the encoding
> is hardcoded? (Perhaps to be more precise, the message body is being
> encoded in the RESTLET component, which for POST means that post data is
> being encoded.)
>
>
>
> willem.jiang wrote:
>
>> Hi,
>>
>> I think you can try to use Camel-Http component, which is leverage
>> common http client to invoke the http service.
>>
>> Willem
>>
>> Bee1000 wrote:
>>
>>> I'm trying to post documents to couchdb using restlet but the restlet
>>> component is hard coded to url encode the post data. This makes the JSON
>>> text i'm posting invalid. Do I need to use some other component or is
>>> there
>>> a way around this?
>>>
>>
>>
>
>
Re: Restlet url encoding post data?
Posted by Bee1000 <ri...@hotmail.com>.
I'd be happy to contribute a fix. Let me take a closer look at it to see if
there was a good reason for the encoding. I think it should do something
similar to the http component, which allows you to set the content type for
posts.
Claus Ibsen-2 wrote:
>
> Hi
>
> We love contributions. So if you want to help out and provide a patch,
> that would be cool.
>
> I am sure restlet support posting data in different encodings.
> Could you create a JIRA ticket, and point out where the hardcoded
> encoding is in the camel-restlet component.
>
>
>
> On Sun, Apr 11, 2010 at 1:49 PM, Bee1000 <ri...@hotmail.com> wrote:
>>
>> Using http does work, but it still seems like a bug to hard code the
>> encoding
>> of post data for restlet. I thought post data could be any text or
>> binary
>> data. It seems like this reduces the usefulness of the restlet camel
>> component. Just out of curiosity, is there another reason why the
>> encoding
>> is hardcoded? (Perhaps to be more precise, the message body is being
>> encoded in the RESTLET component, which for POST means that post data is
>> being encoded.)
>>
>>
>>
>> willem.jiang wrote:
>>>
>>> Hi,
>>>
>>> I think you can try to use Camel-Http component, which is leverage
>>> common http client to invoke the http service.
>>>
>>> Willem
>>>
>>> Bee1000 wrote:
>>>> I'm trying to post documents to couchdb using restlet but the restlet
>>>> component is hard coded to url encode the post data. This makes the
>>>> JSON
>>>> text i'm posting invalid. Do I need to use some other component or is
>>>> there
>>>> a way around this?
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28208067.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> 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
>
>
--
View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28209614.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Restlet url encoding post data?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
We love contributions. So if you want to help out and provide a patch,
that would be cool.
I am sure restlet support posting data in different encodings.
Could you create a JIRA ticket, and point out where the hardcoded
encoding is in the camel-restlet component.
On Sun, Apr 11, 2010 at 1:49 PM, Bee1000 <ri...@hotmail.com> wrote:
>
> Using http does work, but it still seems like a bug to hard code the encoding
> of post data for restlet. I thought post data could be any text or binary
> data. It seems like this reduces the usefulness of the restlet camel
> component. Just out of curiosity, is there another reason why the encoding
> is hardcoded? (Perhaps to be more precise, the message body is being
> encoded in the RESTLET component, which for POST means that post data is
> being encoded.)
>
>
>
> willem.jiang wrote:
>>
>> Hi,
>>
>> I think you can try to use Camel-Http component, which is leverage
>> common http client to invoke the http service.
>>
>> Willem
>>
>> Bee1000 wrote:
>>> I'm trying to post documents to couchdb using restlet but the restlet
>>> component is hard coded to url encode the post data. This makes the JSON
>>> text i'm posting invalid. Do I need to use some other component or is
>>> there
>>> a way around this?
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28208067.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
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
Re: Restlet url encoding post data?
Posted by Bee1000 <ri...@hotmail.com>.
Using http does work, but it still seems like a bug to hard code the encoding
of post data for restlet. I thought post data could be any text or binary
data. It seems like this reduces the usefulness of the restlet camel
component. Just out of curiosity, is there another reason why the encoding
is hardcoded? (Perhaps to be more precise, the message body is being
encoded in the RESTLET component, which for POST means that post data is
being encoded.)
willem.jiang wrote:
>
> Hi,
>
> I think you can try to use Camel-Http component, which is leverage
> common http client to invoke the http service.
>
> Willem
>
> Bee1000 wrote:
>> I'm trying to post documents to couchdb using restlet but the restlet
>> component is hard coded to url encode the post data. This makes the JSON
>> text i'm posting invalid. Do I need to use some other component or is
>> there
>> a way around this?
>
>
>
--
View this message in context: http://old.nabble.com/Restlet-url-encoding-post-data--tp28197024p28208067.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Restlet url encoding post data?
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
I think you can try to use Camel-Http component, which is leverage
common http client to invoke the http service.
Willem
Bee1000 wrote:
> I'm trying to post documents to couchdb using restlet but the restlet
> component is hard coded to url encode the post data. This makes the JSON
> text i'm posting invalid. Do I need to use some other component or is there
> a way around this?