Thanks for posting your solution. I ran up against this problem a few
days ago and thought I was missing something so started using GET
instead.


On Sep 11, 4:11 am, Vince Bonfanti <vbonfa...@gmail.com> wrote:
> After two days of banging my head against this, it turns out to be a
> bug in the development environment, but works fine on the production
> servers. Silly me for thinking you should make things work in
> development first before deploying to production...  ;-)
>
> Issue #2097 in case anyone's interested in the gory details.
>
> Vince
>
> On Wed, Sep 9, 2009 at 8:20 AM, Vince Bonfanti <vbonfa...@gmail.com> wrote:
> > I'm trying to send binary data--a serialized Java object--via the
> > TaskOptions.payload() method, but can't figure out how to send and/or
> > read the data properly. First, I serialized an object to a byte[],
> > which I know is working properly. Then I set the byte[] as the task
> > payload via:
>
> >    TaskOptions.payload( byte[], contentType );
>
> > I've tried different values for contentType;
> > "application/octet-stream" and "application/x-java-serialized-object"
> > seemed like the two most reasonable, but this seems to have no effect.
>
> > In my task handler (a servlet), I read the data into a byte[] prior to
> > object deserialization via the following:
>
> >   byte[] bytesIn = new byte[ req.getContentLength() ];
> >   req.getInputStream().readLine( bytesIn, 0, bytesIn.length );
>
> > However, the byte[] I read in is not the same as the byte[] I wrote
> > out. Here are the first few bytes of the array as I wrote it to
> > TaskOptions.payload (this is cut-and-paste from the Eclipse debugger):
>
> >   -84, -19, 0, 5, 115, 114, 0, 38, 99, 111, 109, 46, 103, 111,
>
> > and here are the first few bytes I read in, which is tantalizingly
> > close to what was written out:
>
> >    63,  63, 5, 115, 114, 38, 99, 111, 109, 46, 103, 111
>
> > So then I tried a different tack. I converted the byte[] to a string
> > in the outward direction:
>
> >   TaskOptions.payload( new String( byte[] ) );
>
> > and then used req.getReader() to read it in my task handler:
>
> >   byte[] bytesIn = req.getReader().readLine().getBytes();
>
> > This time I got even closer to my original byte[], but it's still
> > missing all of the "0" bytes:
>
> >   -84, -19,  5, 115, 114,  38, 99, 111, 109, 46, 103, 111, 111
>
> > Note that in both cases, the content length reported in the request
> > header is smaller than the byte[] length when I invoked
> > TaskOptions.payload().
>
> > How do I send a byte[] as the task payload? Any clues would be appreciated.
>
> > Vince
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to