users@jersey.java.net

[Jersey] Sending a Header Param in Multipart

From: <tiptronicus_at_gmail.com>
Date: Thu, 20 Oct 2011 00:02:35 +0000 (GMT)

I am trying to send an additional header param in a multipart message
as follows in a Jersey client program

MultiPart multipart = createMultiPartMessage();
multipart.getHeaders().putSingle("newtoken",
UUID.randomUUID().toString());

ClientResponse response =
webResource.path("/send").accept("application/json").type("multipart/mi
xed").post(ClientResponse.class, multipart);

The upload works fine. But on the server when I try to print the
headers of the multipart, I don't see this key. The code is like this

@POST
        @Path("/send")
        @Consumes("multipart/mixed")
        @Produces("application/json")
        public Response uploadData(MultiPart multipart) {

System.out.println(multipart.getHeaders().toString());


and the result looks like this

{accept=[application/json], content-type=[multipart/mixed;
boundary=Boundary_1_986957475_1319068022450], mime-version=[1.0],
user-agent=[Java/1.6.0_27], host=[localhost:8080],
connection=[keep-alive], content-length=[4845778]}

If this is not the right way to pass a custom header, what is?

Thanks,