users@jersey.java.net

[Jersey] Re: Entity streams

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Fri, 29 Apr 2011 09:30:34 +0200

On 4/29/11 4:21 AM, Gili wrote:
> I believe WebResource.get() only returns once the Response is complete;
> otherwise, how can it return the HTTP return-code?
not true; actually http return code is the first information which comes
back from server (it is the very first "line")
> I think we need to register some sort of hook for processing the InputStream
> before invoking get() but no such method seems to exist. Am I overlooking
> something or should I file a RFE?
no, please don't. You can't get access to InputStream before calling
get, because the request wasn't send yet and there is nothing what you
could get at that moment.

Zzantozz is right in this case, WebResource.get(InputStream.class) is
what you are looking for.

Regards,
Pavel
> Gili
>
>
> zzantozz wrote:
>> I've never done it, but my first guess would be:
>> InputStream in = resource. ... .get(InputStream.class);
>>
>> On Thu, Apr 28, 2011 at 2:33 PM, Gili&lt;cowwoc_at_bbs.darktech.org&gt;
>> wrote:
>>
>>> Hi,
>>>
>>> I'd like to define a @GET method whose entity is an OutputStream that
>>> gets
>>> populated slowly over time. Imagine for example, a response that gets
>>> populated with a line of text every second, for a total of one minute.
>>> The
>>> client would like to act on the reply every time a line is added (once a
>>> second) as opposed to waiting for the complete response to be written
>>> (once
>>> a minute).
>>>
>>> I figured out that I'm supposed to use javax.ws.rs.core.StreamingOutput
>>> on
>>> the server-side thanks to
>>>
>>> http://stackoverflow.com/questions/3496209/input-and-output-binary-streams-using-jersey
>>> but it's not clear what I'm supposed to do on the client-side.
>>>
>>> How can I get access the client-side InputStream before the Response is
>>> complete?
>>>
>>> Thanks,
>>> Gili
>>>
>>> --
>>> View this message in context:
>>> http://jersey.576304.n2.nabble.com/Entity-streams-tp6314573p6314573.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Entity-streams-tp6314573p6315471.html
> Sent from the Jersey mailing list archive at Nabble.com.
>