users@jersey.java.net

Re: [Jersey] Message body reader not found - _at_Consumes( "multipart/form-data;boundary=\"foo\"" ) works but @Consumes( "multipart/form-data" ) does not

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 01 Aug 2008 10:42:14 +0200

Martin Grotzke wrote:
> Hi Paul,
>
> I just changed the clients content-type from
>
> r.type("multipart/form-data;boundary=\"frontier\"")
> to
> r.type("multipart/form-data")
>
> and the test runs fine.
>

Ah, it is a bug when comparing media types. The media types are stored
in a hash map where an additional class performs the equality and hash
code generation (as opposed to using the ones in media type that are too
restrictive because they compare parameters). The hash code generation
was incorrect because it deferred to MediaType.hashCode (which was
subsequently modified to include parameters).

I have committed a fix to the trunk.


> I didn't implement this stuff by myself but a colleage did this (he's
> just on holidays), so I don't know why "boundary=\"frontier\"" was
> added.
>

Usually the boundary parameter is set by the serialization mechanism.
Furthermore using a boundary that is a common word like "frontier" is
dangerous, it is better to use a UUID as there is much less chance of
the that occurring in the actual content.

BTW i have added some support for mutilpart/form-data using JavaMail
with @FormParam, but i had to do some extra work to get access to the
content disposition, but additional parameters are not available. This
could do with some improvements.


> Do you think we can safely remove this?
>

Possibly :-) i am not sure on the specifics in this case.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109