Allow request body to come from data structure or file.

If a data structure it is turned into a JSON string. A file
is passed through directly, encoding controlled by whether
the content-type suggests a binary or not.

The handling of data input is getting quite messed up, so could
do with a bit of refactoring. In fact the whole thing could do with
some cleaning up.