Working on our API the other day I came over an incompatibility issue with our front end server and the Dispatch http library. Some web servers does not accept chunked data input by default (nginx for instance) and will reply with a 411 error code.

If you post a file using an InputStream with Dispatch, it will send the data in chunks which is great unless an incompatible server is receiving the data.

You could also post a File directly, but in our case we have the file available as a stream so saving it to file would be inefficient.

A solution is to extend org.apache.http.entity.mime.content.FileBody that will assure that the data is sent without chunking. If we know the content length we can provide it, if not we read the stream to memory to find it.

I also created a SuperMimeRequest extending dispatchs MimeRequest to make it feel more natural.