def get_form_url(request, protocol='http', preview=False):
    """
    Return a form list url endpoint to be used to make a request to Enketo.

    For example, it will return https://example.com and Enketo will know to
    look for the form list at https://example.com/formList. If a username is
    provided then Enketo will request the form list from
    https://example.com/[username]/formList. Same applies for preview if
    preview is True and also to a single form when xform_pk is provided.
    """
    http_host = request.META.get('HTTP_HOST',
        'dev.monitora.sisicmbio.icmbio.gov.br')
    url = '%s://%s' % (protocol, http_host)
    if preview:
        url = '%s/preview' % url
    return '{}/xform'.format(url)
