users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 13 Oct 2009 10:04:57 +0200

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));

Paul.

> interesingly enough, the value gets logged, but I get two stackstraces
> available at http://nagyz.pastebin.com/mfabc115
>
> am I doing it the wrong way? :)
>
> Thanks,
> Zoltan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>