'Perform HTTP request / post to external server.
cmd = remote command to perform (str)
extra_payload = dict of extra stuff to post.
Return XML tree of response (from response body)'

def do_external_request(self, cmd, extra_payload):

    xmlstr = etree.tostring(self.xml, pretty_print=True)
    payload = {'xml': xmlstr, 'edX_cmd': cmd, 'edX_tests': self.tests, 'processor': self.code}
    payload.update(extra_payload)
    try:
        req = requests.post(self.url, data=payload)
    except Exception as err:
        msg = 'Error    {0}    -    cannot    connect    to    external    server    url={1}'.format(err, self.url)
        log.error(msg)
        raise Exception(msg)
    if self.capa_system.DEBUG:
        log.info('response    =    %s', req.text)
    if ((not req.text) or (not req.text.strip())):
        raise Exception(('Error:    no    response    from    external    server    url=%s' % self.url))
    try:
        rxml = etree.fromstring(req.text)
    except Exception as err:
        msg = 'Error    {0}    -    cannot    parse    response    from    external    server    req.text={1}'.format(err, req.text)
        log.error(msg)
        raise Exception(msg)
    return rxml
