Put with no content

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Put with no content

Frank Kolnick
A previous thread seems to indicate that this has been fixed, but I still get a "No Content" error when I send a PUT to a Restlet-based server. (The client uses a library other than Restlet.)

I have the latest stable release of Restlet.

Is there a work-around? Preferably not one that requires inserting dummy content.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3084942
Reply | Threaded
Open this post in threaded view
|

Re: Put with no content

Thierry Boileau-4
Hello,

I dont see clearly the link between the fact that the client sends a PUT request without content and the fact that the client receives a "204 - No content" response.
Could you describe the resource that responses to the call, especially the method that handles the PUT request?

Having said that, I've tested (on both 2.3 and 2.2 branches) the following annotated method. It accepts the empty entity and converts it as a null bean, and returns a 200 response.

    @Put
    public String hello(Contact contact) {
        System.out.println(contact);
        return "hello, world";
    }

With the following code, I notice that the received contact is null, and that the response is "204 - no content" which is correct:
    @Put
    public Contact yop(Contact contact) {
        System.out.println(contact);
        return contact;
    }

best regards,
Thierry Boileau



2014-07-11 17:50 GMT+02:00 Frank Kolnick <[hidden email]>:
A previous thread seems to indicate that this has been fixed, but I still get a "No Content" error when I send a PUT to a Restlet-based server. (The client uses a library other than Restlet.)

I have the latest stable release of Restlet.

Is there a work-around? Preferably not one that requires inserting dummy content.

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

Reply | Threaded
Open this post in threaded view
|

RE: Re: Put with no content

Frank Kolnick
Thanks Thierry.

I believe it happens specifically when the content length is set to zero (from my reading of previous posts on the subject, and from my own specific case).

I have declared simply:

    @Put
    public void update();

The 'update' method is never called. I.e., the client gets the 'no content' response immediately.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3084950
Reply | Threaded
Open this post in threaded view
|

RE: Re: Put with no content

Frank Kolnick
I tried setting the content length to -1, as per MSDN:
"The ContentLength property contains the value of the Content-Length header returned with the response. If the Content-Length header is not set in the response, ContentLength is set to the value -1."

Restlet now complains that the content length must be greater than or equal to zero.

As pointed out by other posters, this is an artificial constraint imposed by Restlet. In many cases, the URI itself carries sufficient information.

I.e., please stop doing that :-)

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085083
Reply | Threaded
Open this post in threaded view
|

RE: Re: Put with no content

Frank Kolnick
Follow-up:

It *does* get through if I can arrange to not set the content length at all. However, this requires some deviousness on the client side. I would personally much prefer if Restlet ignored a content length of zero.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3085084
Reply | Threaded
Open this post in threaded view
|

Re: Re: Put with no content

Thierry Boileau-4
In reply to this post by Frank Kolnick
Hello,

>Restlet now complains that the content length must be greater than or equal to zero.
>As pointed out by other posters, this is an artificial constraint imposed by Restlet. In many cases, the URI itself carries sufficient information.
If I have a look at the HTTP specifications (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13), I'm inclined to say that things are quite clear:
Content-Length    = "Content-Length" ":" 1*DIGIT
Where "digit" is defined as follow (http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2):
 DIGIT          = <any US-ASCII digit "0".."9">
Which is only an answer to this single mail.


Don't worry, I don't forget the global topic, but unfortunately I need a little bit time to answer you.

Best regards,
Thierry Boileau


2014-07-14 17:20 GMT+02:00 Frank Kolnick <[hidden email]>:
I tried setting the content length to -1, as per MSDN:
"The ContentLength property contains the value of the Content-Length header returned with the response. If the Content-Length header is not set in the response, ContentLength is set to the value -1."

Restlet now complains that the content length must be greater than or equal to zero.

As pointed out by other posters, this is an artificial constraint imposed by Restlet. In many cases, the URI itself carries sufficient information.

I.e., please stop doing that :-)

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

Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: Put with no content

Frank Kolnick
Thanks Thierry :-)

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