FYI, I just checked in a check for HTTP 200, so your code should run OK now.
But I'm still curious to know - what is the use case for returning no content
from a GET? I suppose you could be returning response headers only, but that
seems pretty esoteric...
On Apr 27, 2010, at 10:57 AM, Greg Brown wrote:
> It seems odd that a GET request wouldn't return any content. We could check
> for a 200 response before reading from the input stream, but maybe a
> different HTTP method would be more appropriate?
>
>
> On Apr 27, 2010, at 10:23 AM, Alejandro Vilar wrote:
>
>> Hi, I have a query for a rest server which response code is 204, but I have
>> an exception while the response is processed in this section:
>>
>> Class: org.apache.pivot.web.Query
>>
>> // Read the response body
>> if (method == Method.GET) {
>> InputStream inputStream = null;
>> try {
>> inputStream = connection.getInputStream();
>> value = serializer.readObject(new
>> MonitoredInputStream(inputStream));//ßexception
>> } finally {
>> if (inputStream != null) {
>> inputStream.close();
>> }
>> }
>> }
>> And that's because I get a response without content, any way the above code
>> is trying to read the response body and getting the serialized content, as
>> the response code description says "there is no content" maybe this process
>> should be avoided. I can fix it using a empty serializer, but maybe it would
>> be useful a method such asQuery.doNotProcessResponseBody(), or a switch for
>> each type of response code or do not read the content until is required(some
>> kind of cache(?)).
>>
>> What you think?
>>
>> Regards,
>> Alejandro
>>
>> HTTP RFC - 10.2.5 204 No Content
>>
>