Apache's org.apache.http.entity.mime.content.FileBody
is @NotThreadSafe. Can I safely pass multiple post requests having such FileBody over the network. A sample would be via org.apache.http.impl.client.DefaultHttpClient
wherein the receiving servlet is a javax.servlet.http.HttpServlet
? I'm wondering if the receiving servlet might mix up request contents during FileBody processing by org.apache.commons.fileupload.servlet.ServletFileUpload
.
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
...//execute this multiple times in different jvm's
MultipartEntity entity = new MultipartEntity();
... //add other entity parts here
FileBody body = new FileBody(new File(file));
entity.add("file", body);
HttpPost post = new HttpPost();
... //add other post elements here
post.setEntity(entity);
new DefaultHttpClient().execute(post);
Also, which part of FileBody can be @NotThreadSafe? I don't see any relevant static method in it.