I've got a small piece of code which submits an XML entity along with binary data in the same POST. I'm using the httpclient and httpmime for this.
I'm not quite sure if I should set the Content-Type
header for this request. After all, the Content-Type
is both application/xml
and application/octet-stream
.
What's the correct usage for this?
post = new HttpPost(uri);
post.setHeader("Authorization", auth);
// Should I set Content-Type at all?
post.setHeader("Content-Type", mimeType + ";charset=UTF-8");
MultipartEntityBuilder b = MultipartEntityBuilder.create();
b.addTextBody("data", payload, ContentType.APPLICATION_XML);
b.addBinaryBody("file", file);
post.setEntity(b.build());