This looks like a defect in HttpLibrary. Please report it.
If Content-Type is sent as a header to livetest's post method without using content_type argument, the body is not altered.
HttpLibrary is detecting this header and passing the value that through to the content_type arg.
webtest.TestApp._gen_request tries to add a file into the body if content_type is sent and it starts with 'multipart'.
The lines that are causing the problem are:
if 'Content-Type' in self.context.request_headers:
kwargs['content_type'] = self.context.request_headers['Content-Type']
I'm not sure why this was done as adding a 'Content-Type' request header seems sufficient to make a proper request.
You could:
monkey patch HttpLibrary (works but have to make sure the monkey patch is loaded before RF creates an instance of HttpLibrary)
call an alternate keyword in a library that extends HttpLibrary
extend the library through inheritence and use your library instead of HttpLibrary
comment out the problematic lines in the source code (bad idea)
Seems like there should be a Add Attachment keyword that allows you to attach files to the request and let webtest handle building multipart messages.
Option 2 shown below (kw is called post_raw for lack of a better name):
from robot.libraries.BuiltIn import BuiltIn
from robot.api import logger
def post_raw(url):
"""
Issues a HTTP POST request.
`url` is the URL relative to the server root, e.g. '/_utils/config.html'
"""
self = BuiltIn().get_library_instance('HttpLibrary.HTTP')
path = self._path_from_url_or_path(url)
kwargs = {}
logger.debug("Performing POST request on %s://%s%s" % (self.context._scheme, self.app.host, url))
self.context.pre_process_request()
self.context.post_process_request(
self.app.post(path, self.context.request_body or {}, self.context.request_headers, **kwargs)
)