Hi Folks,

Apologies if this is a newbie question; I'm a long time user of httpclient for basic purposes, but am being stumped this week by a more difficult requirement, and wonder if anyone can help.

I need to assemble a multi-part request, consisting of some normal http headers, an xml document in the first mime-part, and a binary document in the second mime-part. I need to augment the mime-parts with their own http headers, also; specifically a Content-Type declaration and a Content-Disposition header for each one (which I believe is allowed by the MIME standard, from what I can discern from the rfc). My current code looks like this:

HttpClient client = new HttpClient();
PostMethod post = new PostMethod(target);

// set the request headers
post.setRequestHeader("Slug", slug);
post.setRequestHeader("X-On-Behalf-Of", user);

// construct the xml and binary file parts
FilePart xmlPart = new FilePart("atom", new File(xml), "text/xml", null);
FilePart binaryPart = new FilePart("binary", new File(binary));

// make the multipart request body
Part[] parts = { xmlPart, binaryPart };
MultipartRequestEntity re = new MultipartRequestEntity(parts, post.getParams());
post.setRequestEntity(re);

// execute the post
client.executeMethod(post);

As you can see, I've got the Content-Type header being set properly in the FilePart constructor, and this works fine. What I can't figure out how to do is add the Content-Disposition header to either of these parts. I've poked around the examples, tutorials and mailing lists but haven't been able to find any examples of this, but I have seen references in the source code to the content disposition in the Part object from which FilePart eventually extends.

Any help or pointers to documentation gratefully appreciated.

All the best,

Richard

--
Richard Jones
Head Repository Systems Architect, Symplectic Limited
e: [email protected]
t: 0845 026 4755
t: +44 (0)207 7334036
w: http://www.symplectic.co.uk/


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to