users@jersey.java.net

Re: [Jersey] Raw stream processing at server side filter

From: Zoltan Arnold NAGY <Zoltan.Nagy_at_Sun.COM>
Date: Tue, 13 Oct 2009 10:51:25 +0200

Paul Sandoz wrote:
>
> On Oct 9, 2009, at 4:06 PM, Zoltan Arnold NAGY wrote:
>
>> Hi,
>>
>> Okay, I've managed to hash the entity on the client side. Now I'm
>> having problem the server side.. :)
>>
>>
>> I've created a filter which implements ContainerRequestFilter. Inside
>> that, I'm trying to do this:
>> try {
>> byte[] bytes =
>> IOUtils.toByteArray(request.getEntityInputStream());
>> log.info("" + bytes.length);
>> } catch(IOException e) {
>> e.printStackTrace();
>> }
>>
>
> You are consuming the request, thus there are no more bytes to read,
> hence the odd error from the JAXB unmarshaller.
>
> You need to do:
>
> request.setEntityInputStream(new ByteArrayInputStream(bytes));
Sounds a bit twisted. :) If that's the case, when does that stream gets
written to?

Isn't the actual entity part of the incoming request? And by request I
mean a PUT/POST request (we might
differ about the terminology, thus the misunderstanding).

Thanks,
Zoltan