While the parameterized header is useful for general operation i do
think we require more direct support for content disposition. We can
use the com.sun.jersey.core.header.ContentDisposition header:
bodyPart.getContentDisposition();
It would also be useful for multipart/form-data to also get the
FormDataContentDisposition. Perhaps it is worth extending MultiPart
and BodyPart to have FormDataMultiPart and FormDataBodyPart and be
able to look up the latter from the former using a name?
Paul.
On Nov 21, 2008, at 8:39 AM, Gili wrote:
>
>
> Craig McClanahan wrote:
>>
>> For *all* HTTP headers, it is legal to have multiple values for the
>> same
>> header, so a general purpose API has to support that option. For the
>> simple case where you know there is only one value (or for where you
>> don't care about anything other than the first value), try this:
>>
>> bodyPart.getParameterizedHeaders().getFirst("Content-
>> Disposition").get("name");
>>
>
> Yeah, I just remembered this when reading an older post you made about
> ParameterizedHeaders. <shudder> HTTP headers sure are complex.
>
> Okay, so I'll get cracking using this new API but I would like to
> humbly
> suggest you need to explain a lot of these details in the Javadoc.
> It should
> be easier for end-users to pick up on these concepts without reading
> through
> the HTTP specification. I suspect that even developers who are quite
> familiar with HTTP will drop the ball on the HTTP header complexity.
>
> I would suggest you write something along the following lines:
>
> [...]
> Here is a sample HTTP header:
> Content-Disposition: attachment; filename=bear.jpeg;
> inline; filename=panda.jpeg;
>
> The above header means: ("Content-Disposition=attachment" and
> "filename=bear.jpeg") or ("Content-Disposition=inline" or
> "filename="panda.jpeg")
>
> Here is some sample code for parsing the header:
> -
> bodyPart.getParameterizedHeaders().getFirst("Content-
> Disposition").getParameters().get("filename")
> returns "bear.jpeg"
> -
> bodyPart.getParameterizedHeaders().get("Content-
> Disposition").get(1).getParameters().get("filename")
> returns "panda.jpeg"
> [...]
>
> BTW: Please note how long this API is turning out to be. Instead of
> getFirst("Content-Disposition").getParameters().get("filename") why
> don't
> you remove getParameters() and place get() directly on the
> ParameterizedHeader?
>
> Gili
> --
> View this message in context: http://n2.nabble.com/jersey-multipart-throwing-NPE-tp1560622p1560741.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>