No entity in empty PUT

3 messages Options
Embed this post
Permalink
gonzajg

No entity in empty PUT

Reply Threaded More More options
Print post
Permalink
I've read that Restlet returns an error if a no-content PUT is sent and that maybe they will change this behaviour.

I favor this a my reason is the following:

If i want to upload a resource to a collection like
PUT users/1/friends/4
There's no need for a content on this PUT. It's absurd to have a parameter that repeats information.

Another option is to make a POST on users/1/friends, but i think the PUT is simpler and clearer.

So now my question: Is there a way to bypass the "missing request entity" with a no-content PUT that does not involve modifying RESTlet source-code?
gonzajg

Re: No entity in empty PUT

Reply Threaded More More options
Print post
Permalink
I've just solved it.
It's ugly but in the creation of the resource I include the line:

request.setEntity(new StringRepresentation("a"));

Note: "new StringRepresentation("")" doesn't work. I think it gives you null
2nd Note: You should be carefull if that decision doesn't not impact other methods. Ex: If you accept POST it will modify your Entity. I only used it because I accept DELETE and PUT only in that resource.

Hope it helps. I listen for better solutions though...


gonzajg wrote:
I've read that Restlet returns an error if a no-content PUT is sent and that maybe they will change this behaviour.

I favor this a my reason is the following:

If i want to upload a resource to a collection like
PUT users/1/friends/4
There's no need for a content on this PUT. It's absurd to have a parameter that repeats information.

Another option is to make a POST on users/1/friends, but i think the PUT is simpler and clearer.

So now my question: Is there a way to bypass the "missing request entity" with a no-content PUT that does not involve modifying RESTlet source-code?
jlouvel

RE: No entity in empty PUT

Reply Threaded More More options
Print post
Permalink
Hi there,

There was a related issue that I've just fixed in SVN 1.1 branch and trunk:

"Empty entity on PUT"
http://restlet.tigris.org/issues/show_bug.cgi?id=803

Note that this only affected the Resource class and not the new
ServerResource one.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com



-----Message d'origine-----
De : gonzajg [mailto:[hidden email]]
Envoyé : vendredi 23 octobre 2009 17:04
À : [hidden email]
Objet : Re: No entity in empty PUT

I've just solved it.
It's ugly but in the creation of the resource I include the line:

request.setEntity(new StringRepresentation("a"));

Note: "new StringRepresentation("")" doesn't work. I think it gives you null
2nd Note: You should be carefull if that decision doesn't not impact other
methods. Ex: If you accept POST it will modify your Entity. I only used it
because I accept DELETE and PUT only in that resource.

Hope it helps. I listen for better solutions though...



gonzajg wrote:

>
> I've read that Restlet returns an error if a no-content PUT is sent and
> that maybe they will change this behaviour.
>
> I favor this a my reason is the following:
>
> If i want to upload a resource to a collection like
> PUT users/1/friends/4
> There's no need for a content on this PUT. It's absurd to have a parameter
> that repeats information.
>
> Another option is to make a POST on users/1/friends, but i think the PUT
> is simpler and clearer.
>
> So now my question: Is there a way to bypass the "missing request entity"
> with a no-content PUT that does not involve modifying RESTlet source-code?

>

--
View this message in context:
http://n2.nabble.com/No-entity-in-empty-PUT-tp3878969p3879255.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=24106
72

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2413701